After having solved a number of memory leaks in my application, I suddenly had
one again after introducing jModalFrame.
It is my impression that JMF registers itself with KeyboardFocusManager. KFM is
a singleton, and registering an object as a PropertyChangeListener, but never
unregistering, means that the listener is never garbage collected.
After resolving a number of KeyboardFocusManager related memory leaks, I often
resorted to the "middle man" approach. An middle man object registers itself to
the KFM and has a soft/weak link to the actual listener (JMF in this case). If
an event comes it, the middle man checks the link. If not null, it will forward
the event. If null, it will deregister itself from the KFM, thus allowing for
full garbage collection.