From 75394d6d1ba633f6bf0218f563b8876b824c6fcf Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Sat, 2 Jun 2012 15:47:29 -0700 Subject: [PATCH] Fix bug 6558006: SystemUI native heap is huge. Fix memory leak TextLayoutCache was leaking HB_Face objects, not freeing them when purging the mCachedHBFaces cache. More full analysis is in the bug. Change-Id: Ie5cd8b00c36b9d31963183c601cde49cbb73fafb --- core/jni/android/graphics/TextLayoutCache.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index c85b09c530959..35f82a85b9f04 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -992,6 +992,10 @@ HB_Face TextLayoutShaper::getCachedHBFace(SkTypeface* typeface) { } void TextLayoutShaper::purgeCaches() { + size_t cacheSize = mCachedHBFaces.size(); + for (size_t i = 0; i < cacheSize; i++) { + HB_FreeFace(mCachedHBFaces.valueAt(i)); + } mCachedHBFaces.clear(); unrefTypefaces(); init();