JDK-8269081 : Tree/ListViewSkin: must remove flow on dispose
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-06-21
  • Updated: 2021-09-03
  • Resolved: 2021-09-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx18Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
first cleanup rounds (JDK-8256821 for TreeViewSkin, JDK-8246195 for ListViewSkin) only removed references from the flow to the skin: this seemed to fix memory leaks (and side-effects) for both - but not completely for TreeView, still failing when skin is replaced while the tree is in a scene:

    @Test
    public void testMemoryLeakShowAlternativeSkin() {
        showControl();
        Skin<?> replacedSkin = replaceSkin(control);
        WeakReference<?> weakRef = new WeakReference<>(replacedSkin);
        replacedSkin = null;
        // beware: this is important - we might get false leaks without!
        Toolkit.getToolkit().firePulse();
        attemptGC(weakRef);
        assertEquals("Skin must be gc'ed", null, weakRef.get());
    }
    
Since then, we learned a bit - in particular to remove all direct children that the skin has added, here that would be the flow. Doing so lets the test pass.

Aside: the same test for ListViewSkin passes. Which was puzzling, given everything else related to the flow is the exact same - or so it looks: the difference is the default cellFactory - in listViewSkin it's a static method, in treeViewSkin it's an instance method (keeping an implicit reference to the skin?).




Comments
Changeset: e9315014 Author: Jeanette Winzenburg <fastegal@openjdk.org> Date: 2021-09-02 11:30:58 +0000 URL: https://git.openjdk.java.net/jfx/commit/e9315014f4accd97d757689d5ff212dd536a6e61
02-09-2021