Gauge memory leak
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)
-
-
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 ?
-
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.
-
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?
-
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.
-
repo owner Made a test on my Linux machine with Ubuntu, OpenJDK 1.8u66 and OpenJFX. I see no memory leak... ???
-
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.
-
reporter - changed status to resolved
Resolving - I am seeing the same issue with some of the animated examples from http://download.oracle.com/otndocs/products/javafx/2/samples/Ensemble/index.html#SAMPLES. This issue appears to be being caused by a native library that JavaFX is using and therefore is not directly related to this library.
-
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!
- Log in to comment
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.