-
Bug
-
Resolution: Fixed
-
P4
-
jfx11, jfx21
-
b18
-
os_x
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8337649 | jfx21.0.5 | Johan Vos | P4 | Resolved | Fixed | b01 |
On macOS, when MenuBar.setUseSystemMenuBar set to true, there is a memory leak of javafx.scene.control.MenuItem and com.sun.glass.ui.MenuItem instances (among others), that can be seen if you remove and add MenuItems repetitively.
The attached test application can reproduce the issue. It iterates 100 times with a delay of 0.1 second.
To reproduce, just start the app, wait around 10 seconds, and see the output:
Live MenuItems: 101
This doesn't happen when MenuBar.setUseSystemMenuBar is false. In this case, as expected:
Live MenuItems: 1
Running VisualVM after the test, and doing a heap dump and filter Objects on "menu" shows the leak on different objects (See heapdump-menu.png)
Also, the GC root points a JNI reference (See gc-root.menuitem1.png)
which might indicate that a native object is not freed after the (Java) MenuItem is removed. Enabling native debug logs also indicates that dealloc (in mac/GlassMenu.m) is never called.
The issue happens on any macOS architecture and with any JavaFX version.
The attached test application can reproduce the issue. It iterates 100 times with a delay of 0.1 second.
To reproduce, just start the app, wait around 10 seconds, and see the output:
Live MenuItems: 101
This doesn't happen when MenuBar.setUseSystemMenuBar is false. In this case, as expected:
Live MenuItems: 1
Running VisualVM after the test, and doing a heap dump and filter Objects on "menu" shows the leak on different objects (See heapdump-menu.png)
Also, the GC root points a JNI reference (See gc-root.menuitem1.png)
which might indicate that a native object is not freed after the (Java) MenuItem is removed. Enabling native debug logs also indicates that dealloc (in mac/GlassMenu.m) is never called.
The issue happens on any macOS architecture and with any JavaFX version.
- backported by
-
JDK-8337649 macOS: Memory leak with MenuItem when Menu.useSystemMenuBar(true) is used
- Resolved
- relates to
-
JDK-8323787 Mac System MenuBar throws IOB exception
- Resolved
- links to
-
Commit openjdk/jfx/8dd3c37c
-
Commit(master) openjdk/jfx21u/e6f725f5
-
Review openjdk/jfx/1277
-
Review(master) openjdk/jfx21u/65
(1 links to)