Gauge memory leak

Create issue
Issue #41 resolved
Jack Williams created an issue

When repeatedly updating the value of a gauge, memory is leaked. The following example leaks 100mb on my system every iteration.

Environment details:

OS: Linux x86_64, Java Version: 1.8 openjdk, Enzo Version: 0.32,

import eu.hansolo.enzo.gauge.RadialSteelGauge;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;


public class Main extends Application
{
    private long lastTimerCall;
    private AnimationTimer timer;


    @Override
    public void start ( Stage stage ) throws Exception
    {
        HBox pane = new HBox();
        pane.setPadding( new Insets( 10, 10, 10, 10 ) );
        pane.setSpacing( 10 );
        final RadialSteelGauge gauge = new RadialSteelGauge();
        pane.getChildren().add( gauge );

        final Scene scene = new Scene( pane, Color.BLACK );

        lastTimerCall = System.nanoTime();
        timer = new AnimationTimer()
        {
            @Override
            public void handle ( long now )
            {
                if ( now > lastTimerCall + 1000000000 )
                {
                    gauge.setValue( Math.random() * 101 );
                    lastTimerCall = now;
                }
            }
        };

        stage.setScene( scene );
        stage.show();

        timer.start();

    }

}

Comments (9)

  1. Patrick Kutch

    Must be something new. I'm using a slightly older build and have had literally dozens of gauges running for over a week, and was monitoring for memory leaks.

  2. Gerrit Grunwald repo owner

    Hmm...just testing Enzo 0.3.4 with Oracle JDK8u51 on OS X and everything looks fine...no memory leaks so far. What JDK8 version do you use ?

  3. Jack Williams reporter

    I have just tried the same example with 0.3.4 and its still leaking memory, interestingly though I tried it on a Windows 7 VM and memory usage appeared to be stable. In both cases JDK8u66 was used.

  4. Gerrit Grunwald repo owner

    Could it be related to OpenJDK on Linux compared to Oracle JDK on Mac and Windows? Can you try on Linux with Oracle JDK?

  5. Jack Williams reporter

    Just tried Oracle 1.8u66 with the same result. I also attached a profiler and while the system ram usage is climbing rapidly, none of the JVM's common memory spaces are increasing even close to the same rate. The heap doesn't get over 200mb before it gets GC'd.

  6. Gerrit Grunwald repo owner

    Made a test on my Linux machine with Ubuntu, OpenJDK 1.8u66 and OpenJFX. I see no memory leak... ???

  7. Jack Williams reporter

    I seem to be having the same problem. I setup a VM with a new install of Antergos ( the linux distro I am using ) but cannot replicate the issue on it. This probably points to some library I have directly or indirectly installed on my system which JavaFX links against. Unfortunately I do not currently have enough knowledge of how JavaFX renders its graphics on linux to start looking into what it could be.

    I will let you know if I find anything to the contrary, but i think the problem probably isn't directly related to this library.

  8. Jack Williams reporter

    Quick update, this problem appears to be down to the animation setAnimated( false ) resolves this issue entirely. Unfortunately this does not look as good!

  9. Log in to comment