0

When I call scatterChart.getData().clear(), Java is not freeing up memory. For example if I run the following code:

for (int i=0; i<20000; i++) {
    double x = Math.random() * 100.0;
    double y = Math.random() * 500.0;
    ScatterChart.Data<Number,Number> dataPoint = new 
        ScatterChart.Data<Number, Number>(x,y);
   series.getData().add(dataPoint);
}
scatterChart.getData().add(series);

And then call scatterChart.getData().clear() no memory gets cleared. Calling System.gc() explicitly doesn't clear any memory. Any idea what is going on? I don't have references to these points anywhere else in my code.

  • For more clarity, your [profiler](http://stackoverflow.com/q/2064427/230513) may [be able](https://stackoverflow.com/a/14492574/230513) to "Force the VM to perform a garbage collection." – trashgod Sep 07 '17 at 22:04
  • 1
    If you repeatedly do this, do you actually run out of memory? There's no definitive evidence of a memory leak here. E.g. when you clear the data from the chart, the scene graph will likely still retain references to the nodes that are used to render the data until (at least) the next rendering pulse - so maybe you would need to arrange for `System.gc()` to be called *after* that happens (which is not trivial). – James_D Sep 08 '17 at 02:01

0 Answers0