Skip to content

Commit ab424e6

Browse files
author
Marko Brčić
committed
potential solution to rare out of memory problems
1 parent 215ce2d commit ab424e6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

MPChartLib/src/com/github/mikephil/charting/renderer/LineChartRenderer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,15 @@ public Bitmap.Config getBitmapConfig() {
727727
* Releases the drawing bitmap. This should be called when {@link LineChart#onDetachedFromWindow()}.
728728
*/
729729
public void releaseBitmap() {
730+
if (mBitmapCanvas != null) {
731+
mBitmapCanvas.setBitmap(null);
732+
mBitmapCanvas = null;
733+
}
730734
if (mDrawBitmap != null) {
731735
mDrawBitmap.get().recycle();
732736
mDrawBitmap.clear();
733737
mDrawBitmap = null;
734738
}
739+
System.gc();
735740
}
736741
}

MPChartLib/src/com/github/mikephil/charting/renderer/PieChartRenderer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,15 @@ protected void drawRoundedSlices(Canvas c) {
919919
* Releases the drawing bitmap. This should be called when {@link LineChart#onDetachedFromWindow()}.
920920
*/
921921
public void releaseBitmap() {
922+
if (mBitmapCanvas != null) {
923+
mBitmapCanvas.setBitmap(null);
924+
mBitmapCanvas = null;
925+
}
922926
if (mDrawBitmap != null) {
923927
mDrawBitmap.get().recycle();
924928
mDrawBitmap.clear();
925929
mDrawBitmap = null;
926930
}
931+
System.gc();
927932
}
928933
}

0 commit comments

Comments
 (0)