JDK-8175358 : Memory leak when moving MenuButton into another Scene
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8,9,openjfx11,openjfx14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-02-21
  • Updated: 2020-04-29
  • Resolved: 2020-04-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx15Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
I'm still able to reproduce the issue using 9-ea+155.

To simplify the setup I have written a new test case that removes a MenuButton from the scene, but the accelerator on the item is still active.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCombination;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MenuButtonMemoryLeakTest extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		VBox vbox = new VBox();
		
		// create MenuButton having one item
		MenuButton menuButton = new MenuButton();
		MenuItem item = new MenuItem();
		item.setAccelerator(KeyCombination.keyCombination("Ctrl+T"));
		item.setOnAction(e -> new Alert(AlertType.INFORMATION, "Hello from removed menu item").showAndWait());
		menuButton.getItems().add(item);

		
		// add a button to remove the MenuButton
		Button button = new Button("Click me");
		button.setOnAction(e -> {
			vbox.getChildren().setAll(new Label("MenuButton removed. Now press Ctrl-T"));
		});

		vbox.getChildren().addAll(button, menuButton);

		Scene scene = new Scene(vbox, 300, 100);
		stage.setScene(scene);
		stage.show();
	}

	public static void main(String[] args) throws Exception {
		Application.launch(args);
	}
}
---------- END SOURCE ----------


Comments
Changeset: 818ac007 Author: Ajit Ghaisas <aghaisas@openjdk.org> Date: 2020-04-28 05:57:31 +0000 URL: https://git.openjdk.java.net/jfx/commit/818ac007
28-04-2020

Deferred to 10 -- not enough time and too high risk
23-02-2017

Verified in 8u121, 9-ea+156 in both windows & linux. It's reproducible. MenuItem accelerator working even after removing the same menuItem dynamically. ILW=MMM=P3 Moving to dev team for further check.
22-02-2017