Lucee 6.2 non-heap memory usage and class loading

I’ve created a JIRA issue to cover this: Jira

But essentially, we’re seeing a reappearance of class loader issues where classes get reloaded into the code cache repeatedly and never cleared.

I’m just trying out the latest stable 6.1 build to see if the same issue appears, but we got this after upgrading from 5.4 → 6.2.

Update: First few hours of monitoring in 6.1 shows that 6.1 is not showing the same behaviour as 6.2

Graphs in the JIRA issue show the behaviour.

Based on diffing the versions I have that work vs don’t work, I suspect that the following ticket may be the cause:

https://luceeserver.atlassian.net/browse/LDEV-5063

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.

Update 3: Even though that ticket has a fix version of 6.2.0.40 - it has subsequent commits that made it into later tags that appear to cause the problem. The problem first appears in 6.2.0.48-SNAPSHOT, and appears to be caused by this commit: LDEV-5063 - change visibility to PhysicalClassloader to allow loading… · lucee/Lucee@5af36d0 · GitHub

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.