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

Memory leak in ScrollPane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • 8
    • javafx
    • Win7 Java 8b106

      Execute the test below - when the scrollpane is removed it's still referenced so it can't get GC'd.

      public class ScrollPaneMemoryLeakTest extends Application
      {
        private MyScrollPane myPane;
        
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage stage)
        {
          final FlowPane root = new FlowPane(10, 10);
          
          myPane = new MyScrollPane();
          root.getChildren().add(myPane);
          
          Button b = new Button("Remove Pane");
          b.setOnAction(new EventHandler<ActionEvent>()
          {
            @Override
            public void handle(ActionEvent event)
            {
              root.getChildren().remove(myPane);
              myPane = null;
            }
          });
          root.getChildren().add(b);
          
          Scene scene = new Scene(root, 800, 600);
          stage.setScene(scene);
          stage.show();
        }

        private static class MyScrollPane extends ScrollPane
        {
        }
      }

            miflemi Mick Fleming
            wzberger Wolfgang Zitzelsberger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: