|
OutOfMemoryError when using SplineLayer and LinearScale |
Posted by Adrian on Jul-18-2011 10:47 |
|
Hi,
I'm getting an error in my program when I use a line chart with a curve (SplineLayer) and when I set an upperLimit for setlinearScale() on the yAxis.
The issue only happens when the upperLimit value is much lower than a large value in the Y data. Now, I'm going to write code to prevent the "upperLimit" from being too low if one of the coordinates in the y data is very high. But I'm curious to know why this error only happens when using SplineLayer. It works fine for non-spline line charts.
Any ideas?
Thanks
Error Message
-------------
17-Jul-2011 10:24:11 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
Code for Line Chart
-------------------
SplineLayer splineLayer = c.addSplineLayer();
/* addData code goes here */
c.yAxis().setLinearScale(Chart.NoValue, myUpperLimit);
Value of data at runtime
------------------------
myUpperLimit = 220.0
Y Data coordinates = 721481, 721, 761
Tech Info
-----------------------
Java 1.6
Tomcat 6
ChartDirector 5.0 |
Re: OutOfMemoryError when using SplineLayer and LinearScale |
Posted by Peter Kwan on Jul-19-2011 01:26 |
|
Hi Adrian,
Sorry for this problem. We are aware of this bug. This will be fixed in the next version of ChartDirector.
For straight lines, ChartDirector will clip the lines first, and plot only the part that is within the chart. So it works normally.
For spline curves, the industry standard rendering method is to convert the spline curve into many straight line segments, and render the straight line segments. As long as the conversion error is less than a fraction of a pixel, it is not noticible. ChartDirector is usually this method.
The error occurs during the conversion from spline into striaght line segments. For the case in your example, the spline curve can be over a million pixels long (most of which is outside the chart). It may get converted into hundreds of thousands of line segments, and the system runs out of memory.
So the actual issue is not the actual rendering of the line segments (which are always clipped first), but in converting the spline into straight line segments. That's why it occurs only in splines.
In the next version of ChartDirector, an additional clipping stage will occur when converting the spline into straight line segments. This should solve the problem.
Regards
Peter Kwan |
Re: OutOfMemoryError when using SplineLayer and LinearScale |
Posted by Adrian on Jul-19-2011 02:41 |
|
Thanks Peter. I figured it was a bug but thought that perhaps you had a fix or a work around. I'll just add some custom validation.
Any idea when the next version of CD will be released?
Thanks |
Re: OutOfMemoryError when using SplineLayer and LinearScale |
Posted by Peter Kwan on Jul-20-2011 02:11 |
|
Hi Adrian,
The next version should be available within this quarter.
Regards
Peter Kwan |
|