#1111 possible infinite loop in DateAxis.refreshTicksHorizontal

1.0.x
open
nobody
None
5
2017-02-07
2013-06-04
No

I set up a set of data (dates) for a chart and created a DateAxis for it, but accidentally gave very large values for the dates (typical values of Java dates * 1000). This resulted in several minutes of high CPU usage, and finally the following error:

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1694)
at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1556)
at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:809)
at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:3119)
at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:3077)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3220)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1237)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1672)
at javax.swing.JComponent.paint(JComponent.java:1037)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at org.netbeans.swing.tabcontrol.TabbedContainer.paint(TabbedContainer.java:973)
at javax.swing.JComponent.paintChildren(JComponent.java:870)
at javax.swing.JComponent.paint(JComponent.java:1046)
at javax.swing.JComponent.paintChildren(JComponent.java:870)

Discussion

  • Stefan Vahlgren

    Stefan Vahlgren - 2017-02-01

    Hi.
    I've just experienced this and I tracked it down to that this happens for me only when I am using absolute timestamps as values to the DateAxis. After some time of execution, the chart sudently wants to calculate every millisecond from 1970 until current date and put each of these values as a DateTick into an ArrayLIst. Of cource this will case an OutOfMemoryError. This must be a bug!

    I'm using jfreechart 1.0.13

     
  • Stefan Vahlgren

    Stefan Vahlgren - 2017-02-01

    I've just verified that this bug exists in the currently latest release 1.0.19 as well.

    Two possible ways around this:
    1. Dont use absolute timestamps (the once calcualted from 1970) as the value for the DateAxis. Instead calculate a relative timevalue and use that.
    2. Use another another Axis instead of DateAxis.

     
  • Stefan Vahlgren

    Stefan Vahlgren - 2017-02-07

    I've found the root cause now. I will suggest a fix to the jfreechart team

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks