MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

LineChartRenderer mImageCaches can cause OOM

Open natebragg opened this issue 7 years ago • 5 comments

Using MPAndroidChart v3.0.1, I have a line chart depicting dynamic (never the same), frequently-updated data. After a few minutes on my Nexus 10, it would run out of memory. Looking at the heap dump from Android Monitor led me to discover that mImageCaches was caching all of my expired data,, and never evicting anything.

I verified this by, for each of my LineDataSets, calling ds.setDrawCircles(false), which stopped it from running out of memory since it breaks out before inserting into the cache (I stopped testing after there was no heap increase in a couple hours); this is the workaround I am using for now, but I would like to be able to use the circles.

natebragg avatar Mar 20 '17 16:03 natebragg

Got the sames issue master branche. LineChartRenderer.mImageCaches never flushed and causes memory leaks.

https://github.com/PhilJay/MPAndroidChart/blob/c1f6fcebf0c3516e067b34312b283189f909bde5/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java#L643

Dabada avatar Aug 31 '18 17:08 Dabada

Given how long this has sat here, I have my doubts about it being addressed.

natebragg avatar Aug 31 '18 17:08 natebragg

natebragg, I'v taken your fix to my brancher. It works well and eliminate the OOM. Thank's

Dabada avatar Sep 03 '18 01:09 Dabada

Hello, I strongly believe that the problem still exists in v3.1.0. Is it possible to clear this cache somehow and keep the circle drawing functionality?

tsm avatar Feb 22 '22 14:02 tsm

Workaround: reusing old DataSets, so cache will be reused

tsm avatar Feb 22 '22 16:02 tsm