MPAndroidChart
MPAndroidChart copied to clipboard
LineChartRenderer mImageCaches can cause OOM
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 LineDataSet
s, 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.
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
Given how long this has sat here, I have my doubts about it being addressed.
natebragg, I'v taken your fix to my brancher. It works well and eliminate the OOM. Thank's
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?
Workaround: reusing old DataSets, so cache will be reused