When using an XYStepRenderer together with a user-defined BasicStroke (dotdash) the zooming behaviour at some point started to perform really bad. The CPU usage went straight up to the top and the javaw.exe process startet consuming over 1 GB of memory until finally it crashed with an OutOfMemory error.
What amazed me most was:
- It only occurs with a "dotdash" stroke together with XYStepRenderer/XYSplineRenderer
- Memory is not allocated on the managed heap according to JVisualVM (see image 1)
To reproduce this behaviour run the application below and start zooming in. How deep you have to zoom? Check out image 2 to get an idea.
Image 2
Code: Select all
public class ZoomingBug {
public static void main(String[] args) {
XYSeries series = new XYSeries("series1");
series.add(5, 3);
series.add(4, 3);
series.add(3, 2);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
JFreeChart chart = ChartFactory.createXYLineChart("Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
// Problem only occurs when using XYStepRenderer or XYSplineRenderer together with a "dotdash-stroke"
XYStepRenderer renderer = new XYStepRenderer();
renderer.setSeriesStroke(0, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[] {3 * 3, 3, 3, 3}, 0.0f));
plot.setRenderer(renderer);
ChartFrame frame = new ChartFrame("chart", chart);
frame.pack();
frame.setVisible(true);
}
}
Thanks
Matthias