FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.10586]
A DESCRIPTION OF THE PROBLEM :
Memory usage keeps increasing when there's a indeterminate ProgressBar or ProgressIndicator on scene. The moment the progressBar or ProgressIndicator is removed or set to a determinate value, the memory stops increasing.
Note: At some point ( Usually at 40MB ) the memory usage will go back to normal, but it will again keep increasing until it reaches this point again.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a JavaFX ProgressBar or ProgressIndicator
2) Set it to be indeterminate by calling "progress.setProgress(-1);"
3) Add it to the Scene, add the Scene to the Stage and display the Stage.
4) Monitor memory usage
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For a basic application the beginning memory usage will be at 10MB. Once the ProgressBar or ProgressIndicator is set to indeterminate, it'll start rising at a pace of about 0.5MB per second. Once it reaches the point of about 40-45MB, it'll go back to normal, but continue to rise.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package xyz.spajk.java.memleak;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ProgressLeak extends Application
{
// If set to true, RAM will be output to GUI instead of console
public static boolean outputGUI = true;
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
primaryStage.setTitle("ProgressBar memory leak");
VBox root = new VBox();
root.setAlignment(Pos.CENTER);
root.setSpacing(10);
ProgressBar progress = new ProgressBar();
progress.setProgress(-1);
Button changeButton = new Button("Change");
changeButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
if(progress.isIndeterminate())
{
progress.setProgress(0.5);
}
else
{
progress.setProgress(-1);
}
}
});
root.getChildren().addAll(progress, changeButton);
Scene scene = new Scene(root, 710, 400);
primaryStage.setScene(scene);
primaryStage.show();
Thread rammonitor = new Thread() {
@Override
public void run() {
Runtime rt = Runtime.getRuntime();
long usedKB = (rt.totalMemory() - rt.freeMemory()) / 1024;
System.out.println("Ram usage: " + usedKB);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
run();
}
};
rammonitor.start();
}
}
---------- END SOURCE ----------
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.10586]
A DESCRIPTION OF THE PROBLEM :
Memory usage keeps increasing when there's a indeterminate ProgressBar or ProgressIndicator on scene. The moment the progressBar or ProgressIndicator is removed or set to a determinate value, the memory stops increasing.
Note: At some point ( Usually at 40MB ) the memory usage will go back to normal, but it will again keep increasing until it reaches this point again.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a JavaFX ProgressBar or ProgressIndicator
2) Set it to be indeterminate by calling "progress.setProgress(-1);"
3) Add it to the Scene, add the Scene to the Stage and display the Stage.
4) Monitor memory usage
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For a basic application the beginning memory usage will be at 10MB. Once the ProgressBar or ProgressIndicator is set to indeterminate, it'll start rising at a pace of about 0.5MB per second. Once it reaches the point of about 40-45MB, it'll go back to normal, but continue to rise.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package xyz.spajk.java.memleak;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ProgressLeak extends Application
{
// If set to true, RAM will be output to GUI instead of console
public static boolean outputGUI = true;
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
primaryStage.setTitle("ProgressBar memory leak");
VBox root = new VBox();
root.setAlignment(Pos.CENTER);
root.setSpacing(10);
ProgressBar progress = new ProgressBar();
progress.setProgress(-1);
Button changeButton = new Button("Change");
changeButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
if(progress.isIndeterminate())
{
progress.setProgress(0.5);
}
else
{
progress.setProgress(-1);
}
}
});
root.getChildren().addAll(progress, changeButton);
Scene scene = new Scene(root, 710, 400);
primaryStage.setScene(scene);
primaryStage.show();
Thread rammonitor = new Thread() {
@Override
public void run() {
Runtime rt = Runtime.getRuntime();
long usedKB = (rt.totalMemory() - rt.freeMemory()) / 1024;
System.out.println("Ram usage: " + usedKB);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
run();
}
};
rammonitor.start();
}
}
---------- END SOURCE ----------
- is blocked by
-
JDK-8090322 Need new tree visible property in Node that consider Scene and Stage visibility
- Resolved