Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269081

Tree/ListViewSkin: must remove flow on dispose

XMLWordPrintable

      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?).



            fastegal Jeanette Winzenburg
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: