<Swing Dev> RFR: 4907798: MEMORY LEAK: javax.swing.plaf.basic.BasicPopupMenuUI$MenuKeyboardHelper

Sergey Bylokhov serb at openjdk.java.net
Tue Nov 3 18:49:02 UTC 2020


On Tue, 3 Nov 2020 10:32:01 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

> 4907798: MEMORY LEAK: javax.swing.plaf.basic.BasicPopupMenuUI$MenuKeyboardHelper

Changes requested by serb (Reviewer).

test/jdk/javax/swing/JMenu/PopupReferenceMemoryLeak.java line 100:

> 98:             }
> 99:             robot.waitForIdle();
> 100:             robot.keyPress(KeyEvent.VK_ALT);

Can we skip the robot interaction and instead show the popup menu ourselves? (not via menu items)

test/jdk/javax/swing/JMenu/PopupReferenceMemoryLeak.java line 57:

> 55:         try {
> 56:             // Set system look and feel
> 57:             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

I suggest checking all installed L&Fs for example https://github.com/openjdk/jdk/pull/989/files

test/jdk/javax/swing/JMenu/PopupReferenceMemoryLeak.java line 89:

> 87:             for(int i=0; i<3; i++) {
> 88:                 try {
> 89:                     ArrayList gc = new ArrayList();

It will be useful to call System.gc() and limit the size of the heap via -mx

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java line 1229:

> 1227:                 // and uninstall menu keybindings
> 1228:                    removeItems();
> 1229:                    menuInputMap = null;

Just curious, will the uninstall(); at the start of the method will clear this flag as well?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1035


More information about the swing-dev mailing list