RFR: 8208088: Memory Leak in ControlAcceleratorSupport [v6]

Marius Hanl mhanl at openjdk.java.net
Fri Sep 10 11:31:03 UTC 2021

On Fri, 10 Sep 2021 10:30:07 GMT, RationalityFrontline <github.com+69410606+RationalityFrontline at openjdk.org> wrote:

> After updating to jfx 17, I detected memory leak in my application (every controller that has menu items won't get garbage collected after closing its stage), with visualvm I found it was caused by class ControlAcceleratorSupport. This kind of memory leak doesn't happen on jfx 16, so I guess there is something wrong with this PR.
> I've created a sample project that could reproduce and verify the memory leak: [jfx-test](https://github.com/RationalityFrontline/jfx-test/tree/ControlAcceleratorSupport) (on git branch ControlAcceleratorSupport).
> Run command `gradlew run` and you should see the following ui interface:
> ![image](https://user-images.githubusercontent.com/69410606/132838128-ac5a3883-2170-441f-b926-37bde77751b0.png)
> Clicking button `Call GC and Print MenuItems` will call `System.gc()` and print current ungarbaged menu items to console, clicking menu `Restart Stage` will call `Stage.close()` and launch a new same Stage.
> After clicking `Restart Stage` several times, click `Call GC and Print MenuItems`, you will see lots of ungarbaged menu items. However, by changing jfx version to 16 in `build.gradle.kts`, you will always see only one menu item.
> If menu items are set with action listeners, then these listeners also won't be garbage collected, typically these listeners hold references to controllers, which made all closed controllers leaked. This made jfx 17 unusable.

Could you please report the bug at https://bugreport.java.com/ with a minimum reproducible example (written in Java)?


PR: https://git.openjdk.java.net/jfx/pull/429

More information about the openjfx-dev mailing list