-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8u40
-
Windows 7 64 bits
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 class "RectBounds" of "com.sun.javafx.geom".
Now every time you click on the button, which remove all Menus and add the same Menu, you have instance of RectBounds and PseudoClassState that are created.
Some of them are trashed when you run the Garbage collector, but the number is growing.
Can you confirm that this is a memory leak? If it's confirmed, I've seen quite a lot of these "RectBounds" left reachable when using Tooltip, Hbox, Menus etc.
Tested with JDK 8u40 b15.
"
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 class "RectBounds" of "com.sun.javafx.geom".
Now every time you click on the button, which remove all Menus and add the same Menu, you have instance of RectBounds and PseudoClassState that are created.
Some of them are trashed when you run the Garbage collector, but the number is growing.
Can you confirm that this is a memory leak? If it's confirmed, I've seen quite a lot of these "RectBounds" left reachable when using Tooltip, Hbox, Menus etc.
Tested with JDK 8u40 b15.
- relates to
-
JDK-8093919 [Memory leak] MenuBar MenuBarSkin
- Resolved