A third common source of memory leaks is listeners and other callback
. If you implement APIs where customers register callbacks but they do not clearly register, then unless you take any action, they will deposit. The best way to ensure that callbacks are immediately collected is garbage, for example, to store only weak references to them, by simply collecting them as Keys in WeakHashMap.
I am starting in Java. Can anyone teach me how to make poor references in callback and tell me how they solve memory leak problems? Thank you.
Comments
Post a Comment