jfreechart icon indicating copy to clipboard operation
jfreechart copied to clipboard

Java Freeze using a "large" zoom out on the chart.

Open vgrassaud opened this issue 8 years ago • 6 comments

If we zoom out a lot on a chart (X axis labels are overlapped) the java application freeze. We cannot close any window. We have to kill the java process. This problem can be reproduce using the demo and do a zoom out until have the labels on the X axis overlapped on the chart "Multiple Axis Demo 1" for example

vgrassaud avatar Dec 18 '17 12:12 vgrassaud

I reproduce this issue using 1.5.0 and 1.0.19. with jre8 and jre9

vgrassaud avatar Dec 18 '17 12:12 vgrassaud

This is a known problem, when zooming a lot, the chart throws an Exception (More info here: #64). Try to catch the exception so the UI doesn't freeze, that's the best you can do until the problem gets fixed.

I submitted a PR that fixes this problem but has been totally ignored. I hope they see it soon (The fix: #68).

mayuso avatar Dec 18 '17 12:12 mayuso

I have made a fix for #64, let me see if it also fixes this issue.

jfree avatar Oct 25 '20 06:10 jfree

It looks like this is a different issue - I don't see an exception, just the application hanging. I suspect there is either an endless loop or a very very large number of tick labels being rendered which effectively blocks the application.

jfree avatar Oct 25 '20 06:10 jfree

In fact, it has now ended with an out of memory exception which gives some clues as to what is going on:

Exception in thread "TimerQueue" Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space at java.base/java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2334) at java.base/java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2310) at java.base/java.util.Calendar.setTimeInMillis(Calendar.java:1835) at java.base/java.util.Calendar$Builder.build(Calendar.java:1520) at java.base/sun.util.locale.provider.CalendarProviderImpl.getInstance(CalendarProviderImpl.java:87) at java.base/java.util.Calendar.createCalendar(Calendar.java:1697) at java.base/java.util.Calendar.getInstance(Calendar.java:1644) at org.jfree.chart.axis.DateTickUnit.addToDate(DateTickUnit.java:234) at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1636) at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1515) at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:806) at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:3023) at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:2982) at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3124) at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1285) at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1638) at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074) at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5255) at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1643) at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1618) at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1556) at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323) at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5203) at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5013) at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:865) at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:848) at java.base/java.security.AccessController.executePrivileged(AccessController.java:753) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:848) at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:823) at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:772) java.lang.OutOfMemoryError: Java heap space

jfree avatar Oct 25 '20 06:10 jfree

I'm getting this same OutOfMemoryError when there is an Infinity in the data series. When I make a small adjustment to our data and the number becomes 1e7 then there is no OutOfMemoryError. We actually have a divide by zero that created the Infinity (that's another issue on our end).

jzwolak avatar Feb 01 '22 00:02 jzwolak