Possible Duplicate:
How to avoid memory leaks in callback?
Effective Java says:
A third common source of memory leaks is listeners and other callbacks. If you implement an API where clients register callbacks but don’t deregister them explicitly, they will accumulate unless you take some action. 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.
I am unable to understand this. could someone explain this ?