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

Scene and scenegraph leak when the Stage is closed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u40
    • 8u20
    • javafx
    • None
    • Mac OS X.

      I am in a context where I start a Stage from an eclipse platform. The stage is closed (using the Window Manager close cross button). An heapdump of the eclipse platform shows that a reference is kept on the Scene although the Stage has been closed.

      I have attached a screenshot of VisualVM showing the nearest GC root for the scene (scene-ref.png).
      If multiple Stages are opened and closed, there is a single Scene reference that is kept.

      I have tried to replace the scene root with an empty container to avoid my scenegraph to stay in memory but for some reasons, a reference is kept to my scenegraph from the Scene.oldFocusListener. I attached the nearest GC root of an object inside my scenegraph (oldFocusOwner.png).

      Should we consider this situation as a Leak? Any way to make the Scene to not reference the scene graph?

      The code to start the stage:
      Shell junk = new Shell();
      new FXCanvas(junk, SWT.NONE);
      junk.dispose();
      try {
      Stage stage = new Stage();
      JMCContext ctx = new JMCContext(stage);
      Main.init(ctx);
      ctx.getMainController().selectClasses();
      stage.setTitle(ctx.getTitle());
      stage.setScene(ctx.getScene());
      ctx.getStage().show();
      } catch (Exception e) {
      throw new RuntimeException(e);
      }

        1. oldFocusOwner-ref.png
          oldFocusOwner-ref.png
          82 kB
        2. scene-ref.png
          scene-ref.png
          63 kB
        3. SceneTest.zip
          42 kB
        4. HelloJFXPanelLeakTest.java
          4 kB

            ckyang Chien Yang (Inactive)
            jfdenise Jean-Francois Denise (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: