I have been working on a classloader leak in our application and finally got to a point where all references to the CL were gone. In my memory profiling tool (using YourKit and jmap/jhat), I can force a GC that sometimes will immediately get rid of my classloader, but then other times (depends on application usage but that's as specific as I can get) when I force the GC, the CL instance doesn't go away. I capture a memory snapshot and look at the results and it says that this object exists, but is unreachable.
Here's the wacky part... and I only discovered this by accident.
I can force full GC's all I want but the instance just doesn't go away. HOWEVER, after 10-20 minutes, if I do another full GC, it does get collected.
(During this time period the application is mostly inactive (not totally). My "extended" coffee break was the accident that led to this discovery.)
So my concern about a leak here is gone (hopefully), but the question is now more of trying to explain this behavior.
Anyone know what might cause the sun JVM to decide to not collect an unreachable classloader for 20 minutes?
Sun JVM version details:
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)