We've discovered memory leaks in the TreeView.

      Run the code, click the button several times and watch the memory usage go up very quickly.

      I recognized, that treeView.layout() accelerates the effect, but you can see it, too, if you remove it (you just have to click more often ;-) )

      What I do is, I clear all children of the root node, and add new children every time.

      I guess this issue is related to RT-20616 and RT-16529.

      If you can suggest any workaround, while this hasn't been fixed, it would be fine great!

      How likely is that the memory leaks issues will get fixed in 2.2?
      Our application becomes unusable very quickly due to this bug.

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeView;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class MemoryLeakTest extends Application {

          public static void main(String[] args) throws Exception {

          public void start(Stage stage) throws Exception {
              VBox root = new VBox();

              final TreeItem<String> rootItem = new TreeItem<String>();
              final TreeView<String> treeView = new TreeView<String>(rootItem);


              Button button = new Button("clear + add");
              button.setOnAction(new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent actionEvent) {

                      for (int j = 0; j < 50; j++) {
                          for (int i = 0; i < 500; i++) {
                              TreeItem<String> item = new TreeItem<String>();
                      long totalMemory = Runtime.getRuntime().totalMemory() / 1024;
                      long freeMemory = Runtime.getRuntime().freeMemory() / 1024;
                      System.out.println("Heap use: " + (totalMemory - freeMemory) + " / " + totalMemory + " kB");

              Scene scene = new Scene(root);




            • Assignee:
              jgiles Jonathan Giles
              cschudtjfx Christian Schudt (Inactive)
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: