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

TabPane + TextField combination leaks memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • 7-pool, 8u40
    • javafx
    • MacOS 10.6 + 64bit JDK

      I've found this bug while investigating a leak in the Browser demo. Below is a minimized test. To reproduce, I ran the test under profiler and selected tabs one by one. On each tab I clicked into the text field and typed a few letters into it. Then I closed all tabs except Tab0, and created a heap dump (attached as TextFieldLeak.hprof).

      The dump shows five TextField objects (there should be only one), three of them are referenced from QuantumToolkit.animationRunnable. I suppose this may be related to the blinking caret.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.control.TextField;
      import javafx.stage.Stage;

      public class Test extends Application {

          @Override public void start(Stage stage) {
              TabPane tabs = new TabPane();
              for (int i=0; i<5; i++) {
                  TextField field = new TextField("Field" + i);
                  Tab tab = new Tab("Tab" + i);
                  tab.setContent(field);
                  tabs.getTabs().add(tab);
              }
              stage.setScene(new Scene(tabs));
              stage.sizeToScene();
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }

        1. leak.png
          44 kB
          Jonathan Giles
        2. TextFieldLeak.hprof
          7.94 MB
          Peter Zhelezniakov

            ckyang Chien Yang (Inactive)
            peterz Peter Zhelezniakov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: