No change with JDK8 u11 on Windows8 64bit.
![Sad :(](./images/smilies/icon_sad.gif)
For reference, I'm using the most recent code from
https://github.com/jfree/fxgraphics2d.
Here's some screenshots of the Profiler with and without using
clearRect:
1.5GB Memory usage without
clearRect
jfreefx_demo.png
250MB Memory usage with
clearRect (note, memory consumption continues to grow when you resize the chart, but not as fast).
jfreefx_demo_clearrect.png
For reference, here's the modified demo code:
draw() method with clearRect
Code: Select all
private void draw() {
double width = getWidth();
double height = getHeight();
GraphicsContext gc = this.getGraphicsContext2D();
gc.clearRect(0, 0, width, height);
this.chart.draw(this.g2, new Rectangle2D.Double(0, 0, width, height));
}
start() method with test code
Code: Select all
@Override
public void start(Stage stage) throws Exception {
XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartCanvas canvas = new ChartCanvas(chart);
StackPane stackPane = new StackPane();
stackPane.getChildren().add(canvas);
// Bind canvas size to stack pane size.
canvas.widthProperty().bind(stackPane.widthProperty());
canvas.heightProperty().bind(stackPane.heightProperty());
stage.setScene(new Scene(stackPane));
stage.setTitle("FXGraphics2DDemo1.java");
stage.setWidth(700);
stage.setHeight(390);
stage.show();
Thread t = new Thread(() -> {
try {
for (int i = 0; i < 10000; i++) {
Thread.sleep(10);
Platform.runLater(() -> {
canvas.draw();
});
}
}
catch (InterruptedException ex) {
}
});
t.start();
}