Claude has some things to say about this, though I know that it likes have some confirmation bias. In this ticket, the ResourceClassLoader.java class was removed and its cleanup routines not replaced. Among other things.
Update: Running 6.2.0.39-SNAPSHOT briefly and I can see the old behaviour of classes being unloaded before being loaded again (i.e. no problems).
Update 2: Running 6.2.0.40-SNAPSHOT briefly is also showing good behaviour, so this theory does not ring true. I’ll keep trying to pin down the version in which it changes. Trying the official stable 6.2.0 build next.
The commit in the comment above is definitely the cause. Pinning down the exact problem is slightly trickier.
I have tried several obvious looking changes from the diff with no success.
The major change however, appears to be that the MappingImpl no longer gets a classLoader per class as was introduced in the change from LDEV-4739 which fixed this very same issue from the conversation at Classloading: steadily increases (Lucee 5.4.3.x)
Instead, we get a class loader per physical directory once again and the issue returns. Obviously, there are lots more things going on and I’m trying to pick it apart but its pretty tricky.