weakreference

Android: the GC doesn't respect SoftReferences?

It seams that Dalvik's garbage collector doesn't respect SoftReferences and removes them as soon as possible, just like WeakReferences. I'm not 100% sure yet, but despite the fact that there is still ~3MB of free memory my SoftReferences get cleared after I see "GC freed bla-bla-bla bytes" in LogCat. Also, I saw a comment by Mark Murphy...

Why does exist WeakHashMap, but absent WeakSet?

Hi! From J. Bloch A ... source of memory leaks is listeners ... The best way to ensure that callbacks are garbage collected promptly is to store only weak references to them, for instance, by storing them only as keys in a WeakHashMap. So, why there isn't any WeakSet in java collection framework? Thanks. ...