From J. Bloch
A ... source of memory leaks is listeners ... The best way to ensure that callbacks are garbage collected promptly is to store o
Set weakHashSet = Collections.newSetFromMap( new WeakHashMap());
As seen in Collections.newSetFromMap documentation, passing a WeakHashMap to get a Set.