-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u121
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
MenuBar/MenuBarSkin causing memory leak if tried to be removed from a scene. See code part from jdk8u121 code of com.sun.javafx.scene.control.skin.MenuBarSkin (from line 371):
Utils.executeOnceWhenPropertyIsNonNull(control.sceneProperty(), (Scene scene) -> {
scene.getAccelerators().put(acceleratorKeyCombo, firstMenuRunnable);
// put focus on the first menu when the alt key is pressed
scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
if (e.isAltDown() && !e.isConsumed()) {
firstMenuRunnable.run();
}
});
});
This is the most probable cause that the event handler is not weak so it is never removed so if menubar applied on a scene graph (e.g. via FXML).
This issue is raised and solved in openjdk: https://bugs.openjdk.java.net/browse/JDK-8166950
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a stage with a scene and within that a control that has internal MenuBar; after disposing the control it will remove in memory, as menubar will be refer to the topmost scene.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Control and MenuBar should be garbage collected.
ACTUAL -
Control and MenuBar stays in memory after GC
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
No, we do not use MenuBar for sections of disposable content.
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
MenuBar/MenuBarSkin causing memory leak if tried to be removed from a scene. See code part from jdk8u121 code of com.sun.javafx.scene.control.skin.MenuBarSkin (from line 371):
Utils.executeOnceWhenPropertyIsNonNull(control.sceneProperty(), (Scene scene) -> {
scene.getAccelerators().put(acceleratorKeyCombo, firstMenuRunnable);
// put focus on the first menu when the alt key is pressed
scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
if (e.isAltDown() && !e.isConsumed()) {
firstMenuRunnable.run();
}
});
});
This is the most probable cause that the event handler is not weak so it is never removed so if menubar applied on a scene graph (e.g. via FXML).
This issue is raised and solved in openjdk: https://bugs.openjdk.java.net/browse/JDK-8166950
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a stage with a scene and within that a control that has internal MenuBar; after disposing the control it will remove in memory, as menubar will be refer to the topmost scene.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Control and MenuBar should be garbage collected.
ACTUAL -
Control and MenuBar stays in memory after GC
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
No, we do not use MenuBar for sections of disposable content.
- duplicates
-
JDK-8166950 Memory Leak: MenuBar added to Tab is still referenced on tab close and is not garbage collected
- Resolved