Heap Allocation for ShinobiCharts


#1

Hello, 

So I found a bug with the graph when using it on Android.  If continuously zooming in on a line graph a point will be reached where the graph will stop zooming in and the Android application will freeze up.  Shortly after the application will crash and if it is being monitored using the Logcat there is an error saying " E/dalvikvm-heap(27097): Out of memory on a 184-byte allocation".  Has anyone else experienced this?


#2

Following up: currently, the issue is being temporarily resolved.  It is fixed by using the onAxisRangeChangeListener method onAxisRangeChange to limit how far the user can zoom in on the graph.  In the method, first the type of axis is checked using the axis range type ( arg0.getCurrentDisplayedRange() ).  Once the type of the range is known there is a limit set on the respective axis.  This is done using requestCurrentlyDisplayedRange(…) where the params are the minimum zoom range for the axis determined by the programmer.


#3

Hi Peter,

I am sorry to hear that you are experiencing a crash on ShinobiCharts for Android.

What type of axis are you using on your charts? How far do you have to zoom (ideally to what tick mark frequency) in order to cause the crash? What device is this on and what version of Android is it running? Have you tried the latest version of ShinobiCharts for Android?

Thanks,

Kai


#4

Hello Kai,

Thanks for your response. I am using a NumberAxis as the Y-Axis and a DateTimeAxis as the X-axis.  It is difficult to say the tick mark frequency since we are using degrees as our Y-Axis label but the precision is no more than 1 degree.  By this I mean that if you zoom in on the 70 degree range there will be 19 tick marks all labelled with 70 degrees and if you keep zooming the Y-Axis will decrease (zoom) to 4 tick marks which will all be labelled 70 degrees.  Once it reaches 4 tick marks, if you zoom further, it will reset to 19 tick marks (all labelled 70 degrees) and decrease to 4 and repeat.  After about 20 zooms, the graph will freeze and not zoom any further.  When this occurs the error reported to adb logcat is “E/art     (31518): Throwing OutOfMemoryError “Failed to allocate a 64 byte allocation with 12 free bytes and 12B until OOM” (recursive case)”.

This is running on the Nexus 5 with Android Lollipop (5.0.1). The verison of ShinobiCharts is the latest I believe (1.7.1).

Thanks,

Peter


#5

Hi Peter,

Firstly, thanks for the extra information which you have provided, this helps us to understand the problem further.

From what you have said it appears that to experience the crash you are zooming quite deeply into your data. We do not set any limits to the level of zooming allowed on ShinobiCharts for Android and as such the limit depends on the device. We do acknowledge however that the application crashing is not very graceful and could be handled better by us. What I can say is that to mitigate against this we do provide api methods, which you appear to have used to limit the zoom and prevent the crash. 

In the past we had considered adding a guard into our code to prevent these types of zoom related crashes. The problem we faced is that the level of zoom required to cause the crash varies, depending on many factors including the hardware specification and quantity of data points on the chart. As we want our library to be flexible enough to cover a wide range of devices and Android versions, we felt that allowing the user of the library to set his own limits was a more suitable approach.

Finally, I’d like to apologise once again for any inconvenience this issue may cause.

Thanks and kind regards,

Kai.