<Swing Dev> RFR: 8253977: More memory leaks in client-libs on macOS
Sergey Bylokhov
serb at openjdk.java.net
Mon Oct 5 20:40:55 UTC 2020
On Mon, 5 Oct 2020 19:49:43 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> While working on the JDK-8240709 I have found that the test created for JDK-8134947 (currently executed on macOS only)
> can fail due to memory leaks(more often if change it to be stricter). See my comments inline.
src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java line 227:
> 225: }
> 226: uninstallHierListener(b);
> 227: AquaUtilControlSize.removeSizePropertyListener(b);
A tiny leak existed from the initial Mac OS X Port Project.
src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java line 159:
> 157: if (tf != null) {
> 158: tf.removeFocusListener(getNextButtonHandler());
> 159: tf.removeFocusListener(getPreviousButtonHandler());
We started to add these listeners in JDK-8238824, but forgot to remove it.
src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java line 497:
> 495: public void setBackground(final Color c) {
> 496: super.setBackground(c);
> 497: updateOpaque();
This code was added in the JDK-8033786, when it was implemented it was possible to call this method from the
Window.setBackground() and from the Window.getPeer().setBackground().
Since the Window.setBackground() is always followed by the peer.setOpaque()->updateOpaque(), and now it is not possible
to use the peer directly this method became redundant.
Deleted it in this fix since it generates a bunch of memory garbage.
test/jdk/javax/swing/JFileChooser/FileChooserListenerLeak.java line 60:
> 58: }
> 59:
> 60: private static void checkListenersCount(Component comp) {
Just a test improvement, now we will check the listeners recursively for each component inside FileChooser.
test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java line 83:
> 81: * @run main/timeout=450/othervm UnninstallUIMemoryLeaks
> 82: */
> 83: public final class UnninstallUIMemoryLeaks {
I made this test stricter:
- The execution time is increased to 350 seconds per L&F.
- To minimize the overall time execution the test now forks a subtest for each L&F and run it in parallel
- Now the test recursively checks the number of listeners in all components
- The "-mx12m" option is changed to "-mx9m"
-------------
PR: https://git.openjdk.java.net/jdk/pull/514
More information about the swing-dev
mailing list