FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.2
A DESCRIPTION OF THE PROBLEM :
After displaying the pop-up menu of the ChoiceBox at least once, repeating updating the item throws OutOfMemoryError.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start the test application with the following JVM option. -Xmx64
1) Start the test application with the specified JVM option
2) Click the Change item button
3) Repeat steps 2) until OutOfMemoryError occurs (about 25 times)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
OutOfMemoryError does not occur even if updating is repeated.
ACTUAL -
Processing time increases for each update, and OutOfMemoryError occurs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
//Start the test application with the following JVM option. -Xmx64
public class ChoiceBoxChangeLeakTest extends Application {
private int time = 0;
private ChoiceBox<String> choiceBox;
private Button changeButton;
@Override
public void start(Stage stage) throws Exception {
choiceBox = new ChoiceBox<>();
choiceBox.setPrefWidth(200);
changeButton = new Button("Change item");
changeButton.setPrefWidth(200);
changeItems();
changeButton.setOnAction(event -> changeItems());
Scene scene = new Scene(new VBox(choiceBox, changeButton), 400, 400);
stage.setScene(scene);
stage.show();
Platform.runLater(()->{
//In order to reproduce the memory leak, it is necessary to display the pop-up menu at least once.
choiceBox.show();
});
}
private void changeItems(){
time++;
changeButton.setText("Change item:"+time);
choiceBox.getItems().clear();
for (int i = 0; i < 20; i++) {
choiceBox.getItems().add("Time: " + time +", item:"+i);
}
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.2
A DESCRIPTION OF THE PROBLEM :
After displaying the pop-up menu of the ChoiceBox at least once, repeating updating the item throws OutOfMemoryError.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start the test application with the following JVM option. -Xmx64
1) Start the test application with the specified JVM option
2) Click the Change item button
3) Repeat steps 2) until OutOfMemoryError occurs (about 25 times)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
OutOfMemoryError does not occur even if updating is repeated.
ACTUAL -
Processing time increases for each update, and OutOfMemoryError occurs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
//Start the test application with the following JVM option. -Xmx64
public class ChoiceBoxChangeLeakTest extends Application {
private int time = 0;
private ChoiceBox<String> choiceBox;
private Button changeButton;
@Override
public void start(Stage stage) throws Exception {
choiceBox = new ChoiceBox<>();
choiceBox.setPrefWidth(200);
changeButton = new Button("Change item");
changeButton.setPrefWidth(200);
changeItems();
changeButton.setOnAction(event -> changeItems());
Scene scene = new Scene(new VBox(choiceBox, changeButton), 400, 400);
stage.setScene(scene);
stage.show();
Platform.runLater(()->{
//In order to reproduce the memory leak, it is necessary to display the pop-up menu at least once.
choiceBox.show();
});
}
private void changeItems(){
time++;
changeButton.setText("Change item:"+time);
choiceBox.getItems().clear();
for (int i = 0; i < 20; i++) {
choiceBox.getItems().add("Time: " + time +", item:"+i);
}
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------