Is WeakHashMap ever-growing, or does it clear out the garbage keys?

Yes, keys cleared after garbage is actually collected Yes, WeakHashMap does clean out the detritus. The keys that have gone to garbage collection are no longer reported in the size. But you must wait for garbage-collection to actually take place. Seems likely that you were incorrect about your objects going to garbage-collection. Perhaps your objects … Read more