JDK-8269485 : Showing listener from Node doesn't get removed always and causes memory leaks
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: openjfx16
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-06-28
  • Updated: 2021-06-28
  • Resolved: 2021-06-28
Related Reports
Duplicate :  
Description
The listener showing listener to update the treeShowing Property don't always work properly.
In some situations, the window might change before the old listener is removed.
This is due to too complex listener logic.

More details/tests in the PR
Comments
Bugs should only be closed as "Fixed" as a result of a commit pushed to the repo (and Skara will now take care of that). I am reopening this to close it as a duplicate of JDK-8252935, based on the above comment.
28-06-2021

I've initially written the test for JavaFX16, but it was fixed on the way to JavaFX17 by JDK-8252935 , so the ticket is no longer relevant. This was my unit test: @Test public void leakDeterminationIndicator() throws Exception { JMemoryBuddy.memoryTest((checker) -> { CountDownLatch showingLatch = new CountDownLatch(1); Util.runAndWait(() -> { Scene scene1 = new Scene(new Group()); Scene scene2 = new Scene(new Group()); Group elem = new Group(); Group root = new Group(elem); elem.sceneProperty().addListener((p,o,n) -> { System.out.println("To Scene2!"); scene1.setRoot(new Group()); scene2.setRoot(root); }); scene1.setRoot(root); System.out.println("To Scene1!"); checker.setAsReferenced(scene1); checker.assertCollectable(scene2); checker.assertCollectable(root); }); }); }
28-06-2021