2

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?

blukpun
  • 53
  • 1
  • 5
  • Why do you need to pass -1 to the constructor? – user234461 Mar 19 '16 at 12:13
  • I don't need, without the parameters i get the same result. In my application i'm setting progress to -1 to indicate that there is some work going on the background, but it's not relevant to the current code example. – blukpun Mar 19 '16 at 12:15
  • I can confirm I see the same behavior, but SE is probably not the right place - you should file a bug report. – Itai Mar 19 '16 at 12:21
  • I already filled one, but i want to find some workaround. This issue took me almost three days to find out the source of memory leakage. I ever reinstalled Fedora to check how it will behave on clean os installation. So i don't want any other Linux user to come through all this. – blukpun Mar 19 '16 at 12:26
  • I'm even thinking that on clean Fedora 23 with only jre and no other updates it may work fine, but i want to rest for a while from this bug right now. – blukpun Mar 19 '16 at 12:29
  • There was a bug filed: [JDK-8094829 Memory leak in JavaFX ProgressIndicator](https://bugs.openjdk.java.net/browse/JDK-8094829) and fixed in Java 8u60. You might wish to double-check that you are using a recent JavaFX build, and only file a bug if that is not the case. – jewelsea Mar 19 '16 at 18:22
  • 1
    I saw that bug report and it's not about such an enormous memory leak. If they were using Linux instead on Windows they would see that ProgressIndicator not only is never GC'd, but also occupies tens of gigabytes of memory in a matter of minutes. But it's interesting, they really fixed that bug, because memory usage not growing when progress indicator is hidden. – blukpun Mar 19 '16 at 20:02
  • @jewelsea I get the same on Debian with both OpenJFX 8u60 and the Oracle stock Java 8u73. Additionally, the report linkes only mentions the control staying in memory. With the simple test suggested here, a program running for a mere 30 seconds got to more than 1GB of resident memory. – Itai Mar 19 '16 at 23:26
  • The same problem still occurs with jdk1.8.0_102. – blukpun Sep 23 '16 at 10:16

1 Answers1

1

Log a bug report for such issues:

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.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thank you for such detailed reply, now i'm waiting for evaluation of the issue report and will post reference to the bug if it will be accepted. – blukpun Mar 20 '16 at 19:16
  • The [bug report](https://bugs.openjdk.java.net/browse/JDK-8152426) was marked as duplicate, but it's not really a duplicate of the marked bug. Since only Java developers can comment on the bug reports, I can't tell them it's not the same bug. Are there any Java developers here that can bring this to their attention? The bugs are unrelated, and were wrongly marked as duplicate, making this real bug go unnoticed. – Itai Jul 20 '16 at 22:39
  • @sillyfly post your findings to the [openjfx-dev mailing list](http://mail.openjdk.java.net/mailman/listinfo/openjfx-dev). – jewelsea Jul 20 '16 at 23:01
  • Tried that too. Got back a message that since I'm not registered my message would be inspected by a moderator. Haven't heard anything of it since. I guess I'll have to try to register to the list and try again. – Itai Jul 20 '16 at 23:04