XChart
XChart copied to clipboard
Cursor in LiveChart: Memory Leak and wrong tooltip
How to reproduce:
- Create an XYChart
- XYChart chart = new XYChartBuilder().title("MemoryLeak").xAxisTitle("Date").yAxisTitle("Price").build();
- Enable Cursor
- chart.getStyler().setCursorEnabled(true);
- Add some initial data to chart
- XYSeries chartSeries = chart.addSeries("MemoryLeakSeries", dates, values);
- Show the chart
- SwingWrapper sw = new SwingWrapper(chart); sw.displayChart();
- LiveChart: update the data from time to time
- chart.updateXYSeries("MemoryLeakSeries", updatedDates, updatedValues, null);
- Update the live chart
- javax.swing.SwingUtilities.invokeLater(() -> sw.repaintChart());
-
ISSUE 1: Memory Leak: Wait some time and check memory
- Result:
- Result:
-
ISSUE 2: Wrong cursor info: Check the cursor in the live chart. It shows wrong infos in the tooltip (one can see it at the timestamp. It doesnt match the updated legend. It changes sometimes backwards if the mouse is moved forward. It seems like the cursor data contains ALL elements of ALL Chart updates behind one another)
- Wrong cursor infos:
- Wrong cursor infos:
Having the same symptoms as ISSUE 1 with a real time chart, gigabytes of org.knowm.xchart.internal.chartpart.Cursor$DataPoint held by dataPointList, it seems like. I think Cursor.java and the behaviour of the ArrayLists needs to be investigated.