JRibbonFrame registers several listeners with the AWT Toolkit that are not
removed when the window is disposed(). The culprits are the AWTEventListener
and KeyTipManager.KeyTipListener registered in initRibbonFrame().
If we open up a JRibbonFrame and then close it, all resources associated with
that frame are held onto as it cannot be garbage collected due to these
listeners. This makes a pattern where we construct and show JRibbonFrames on
demand, and then destroy them when they are closed difficult due to the
resulting memory leak.
Since JRibbonFrame is the only supported way of accessing the Ribbon, it is very
hard to work around this. For the AWTEventListener you can work out which
listener the constructor added in a subclass and hold on to a reference to it to
remove it when the frame is closed, but for the key tip listener, there is no
way to view the current listener list and grab the last entry. We could
probably work around this if the KeyTipManager had a public method to return all
listeners--if the larger issue is more difficult to fix in the short term, the
addition of a getKeyTipListeners() method would likely enable a workaround.
These references were from tracing down what was referencing the JRibbonFrame in
the NetBeans heap walker.