diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ActivityThread.java | 3 | ||||
-rw-r--r-- | core/jni/android/graphics/Canvas.cpp | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 09862d2..3bd76a6 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3496,6 +3496,9 @@ public final class ActivityThread { int sqliteReleased = SQLiteDatabase.releaseMemory(); EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased); } + + // Ask graphics to free up as much as possible (font/image caches) + Canvas.freeCaches(); BinderInternal.forceGc("mem"); } diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 605e4b8..bd6fea8 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -21,6 +21,8 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkGLCanvas.h" +#include "SkGraphics.h" +#include "SkImageRef_GlobalPool.h" #include "SkShader.h" #include "SkTemplates.h" @@ -58,8 +60,11 @@ public: return new SkGLCanvas; } - static void freeGlCaches(JNIEnv* env, jobject) { + static void freeCaches(JNIEnv* env, jobject) { + // these are called in no particular order SkGLCanvas::DeleteAllTextures(); + SkImageRef_GlobalPool::SetRAMUsed(0); + SkGraphics::SetFontCacheUsed(0); } static jboolean isOpaque(JNIEnv* env, jobject jcanvas) { @@ -933,7 +938,7 @@ static JNINativeMethod gCanvasMethods[] = { (void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint}, {"native_drawPicture", "(II)V", (void*) SkCanvasGlue::drawPicture}, - {"freeGlCaches", "()V", (void*) SkCanvasGlue::freeGlCaches} + {"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches} }; #include <android_runtime/AndroidRuntime.h> |