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

[Memory leak] MenuBar MenuBarSkin

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      Windows 7 64bits

      Description

      Run this sample test :
      "
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class MenuButtontest extends Application {

          public static void main(String[] args) {
              Application.launch(MenuButtontest.class, args);
          }

          @Override
          public void start(Stage stage) {

              MenuBar bar = new MenuBar();
              Menu menu = new Menu("test");
              bar.getMenus().add(menu);

              MenuItem item = new MenuItem("lol");
              menu.getItems().add(item);
              
              Button button = new Button("add menu");
              button.setOnAction((ActionEvent event) -> {
                  bar.getMenus().clear();
                  bar.getMenus().add(menu);
              });
              BorderPane pane = new BorderPane(button);
              pane.setTop(bar);
              Scene scene = new Scene(pane);
              stage.setScene(scene);
              stage.show();

          }
      }
      "

      Now execute the program and run a memory profiler.
      Get to live result and inspect the classe "MenuBarButton" inside "MenuBarSkin".

      Now every time you click on the button, which remove all Menus and add the same Menu, you have another instance of MenuBarButton created. Nothing is trashed.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jgiles Jonathan Giles
                Reporter:
                shadzic Samir Hadzic
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: