Avoid memory leaks in callbacks?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2859464/how-to-avoid-memory-leaks-in-callback">How to avoid memory leaks in callback?</a>  </p>
</blockquote>



<p>Effective Java says:</p>

<blockquote>
  <p>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.</p>
</blockquote>

<p>I am unable to understand this. could someone explain this ?</p>
