From 48c79b6a75572f8ca14f991be8ddac91a2286c8a Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 9 Dec 2021 19:26:24 +0200 Subject: [PATCH] JFreeChart implementation is leaking memory Take account that new PlotProperties may contain the same objects as the old one. gitlab #86 --- .../src/org/simantics/jfreechart/chart/AbstractPlot.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java index 2d5daec8..5f7c15ef 100644 --- a/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java +++ b/bundles/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/AbstractPlot.java @@ -91,13 +91,16 @@ public abstract class AbstractPlot implements IPlot { protected void setPlotProperties(PlotProperties properties) { if (currentProperties != null) { for (IAxis axis : currentProperties.ranges) - axis.dispose(); + if (!properties.ranges.contains(axis)) + axis.dispose(); for (IAxis axis : currentProperties.domains) - axis.dispose(); + if (!properties.domains.contains(axis)) + axis.dispose(); for (IDataset dataset : currentProperties.datasets) - dataset.dispose(); + if (!properties.datasets.contains(dataset)) + dataset.dispose(); } this.currentProperties = properties; } -- 2.47.1