Issue Description
=============
Whenever you create an indeterminate ProgressIndicator, it will stay in memory forever and with it everything that has a a reference to it.
This issue is quite critical since all our dialogs have kind of a "busy-glass-pane" showing an indeterminate progress indicator asa visual cue that "soemthing" is in progress and disabling mouse/key-inputs, etc. However, there's a workaround for it...
Workaround
=========
Apparently the ProgressIndicator is kept due to an infinite cycle-loop animation. So actually it will be OK memorywise to set progress to 1 (i.e. 100%) before getting rid of it.
Example
=======
Fire up and see that once you open a dialog a progress-indicator will be created and after you close the dialog it will never be GC'd.
package sandbox;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class ProgressIndicatorMemoryLeak extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Button openDialog = new Button("Open Dialog");
openDialog.setOnAction(ae -> {
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
Dialog<String> dialog = new Dialog<>();
dialog.getDialogPane().getButtonTypes().add(loginButtonType);
ProgressIndicator indicator = new ProgressIndicator();
BorderPane content = new BorderPane(indicator);
content.setPadding(new Insets(20));
dialog.getDialogPane().setContent(content);
dialog.show();
});
BorderPane bp = new BorderPane();
bp.setCenter(openDialog);
Scene scene = new Scene(bp, 300, 300);
primaryStage.setTitle("Memory Leak");
primaryStage.setScene(scene);
primaryStage.show();
}
}
=============
Whenever you create an indeterminate ProgressIndicator, it will stay in memory forever and with it everything that has a a reference to it.
This issue is quite critical since all our dialogs have kind of a "busy-glass-pane" showing an indeterminate progress indicator asa visual cue that "soemthing" is in progress and disabling mouse/key-inputs, etc. However, there's a workaround for it...
Workaround
=========
Apparently the ProgressIndicator is kept due to an infinite cycle-loop animation. So actually it will be OK memorywise to set progress to 1 (i.e. 100%) before getting rid of it.
Example
=======
Fire up and see that once you open a dialog a progress-indicator will be created and after you close the dialog it will never be GC'd.
package sandbox;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class ProgressIndicatorMemoryLeak extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Button openDialog = new Button("Open Dialog");
openDialog.setOnAction(ae -> {
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
Dialog<String> dialog = new Dialog<>();
dialog.getDialogPane().getButtonTypes().add(loginButtonType);
ProgressIndicator indicator = new ProgressIndicator();
BorderPane content = new BorderPane(indicator);
content.setPadding(new Insets(20));
dialog.getDialogPane().setContent(content);
dialog.show();
});
BorderPane bp = new BorderPane();
bp.setCenter(openDialog);
Scene scene = new Scene(bp, 300, 300);
primaryStage.setTitle("Memory Leak");
primaryStage.setScene(scene);
primaryStage.show();
}
}
- relates to
-
JDK-8094078 ProgressIndicator/ProgressBar continue to animate when removed or made invisible
-
- Resolved
-