JavaXF 8 ProgressBar and ProgressIndicator with pr

2019-07-14 20:03发布

问题:

Java progress of simple JavaFX application with ProgressBar or ProgressIndicator which progress set to -1 (INDETERMINATE_PROGRESS) gradually uses more and more memory until it fills both ram and swap in just a few minutes.

I'm using Fedora 23 x86_64 with latest updates, kernel-4.4.5-300.fc23.x86_64 and jdk1.8.0_74. The same problem occurs with kernel-4.2.3-300.fc23.x86_64 and both jdk1.8.0_73 and jdk1.8.0_45.

I'm facing this problem in my project and it's occuring even in the simplest application:

package sample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.stage.Stage;

public class ProgressBarMemoryLeak extends Application {

    ProgressIndicator progress = new ProgressIndicator(-1);

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setScene(new Scene(progress, 100, 100));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

Is there any way to overcome this problem?

Maybe there is some other custom ProgressBar implementation i can use instead?

回答1:

Log a bug report for such issues:

  • http://bugreport.java.com

Add a reference to the bug report filed here, so that somebody can track it if they run across this issue.

In the meantime, don't use indeterminate progress on your target platform.

Note that whatever the issue is, it is environment specific (I cannot replicate it on OS X).

Also note that fedora is not a certified system configuration, but hopefully that won't stop the bug report being investigated.