I am currently hunting down a memory leak in Kelvin Kazoom (http://www.digitprop.com/kazoom/index.html
), and have come across a strange phenomenon:
I have app. 20 objects in a Hashtable. I clear() the hash table and am pretty sure that there are no other references to these objects (from looking at the code, and from the very useful Reference Scanner - http://jb2works.com/refscan/usage.html
If I now create WeakReferences on all these objects before clear()'ing the map, then run the garbage collector (via System.gc()), all the WeakReferences show null references (i.e. the objects have been gc'ed) except
for the object last returned by the Hashtable's keys() enumeration.
Has anybody come across something similar? I know that System.gc() is not guaranteed to do anything, but find it very strange that everything is gc'ed except for one object.
When I wait a few seconds, then have a second look, the one remaining object is also eventually gc'ed.
One more detail: Reference Scanner correctly shows the uncollected object, but no references to it. So it seems like the object is not in the GC queue for some reason, but has no references whatsoever.