De-allocate caches for large glyphs when trimming memory
Currently, font renderers eliminate some texture caches when
memory is trimmed. This change makes it go further by eliminating the
large-glyph caches for all font renderers. These caches are
only allocated as needed, but continue to consume large amounts of
memory (CPU and GPU) after that allocation. De-allocating this memory
on a trim operation should prevent background apps from holding onto
this memory in the possible case that they have allocated it by drawing
large glyphs.
Change-Id: Id7a3ab49b244e036b442d87252fb40aeca8fdb26
diff --git a/libs/hwui/GammaFontRenderer.cpp b/libs/hwui/GammaFontRenderer.cpp
index eb863e9..1be957f 100644
--- a/libs/hwui/GammaFontRenderer.cpp
+++ b/libs/hwui/GammaFontRenderer.cpp
@@ -113,6 +113,13 @@
delete mRenderers[min];
mRenderers[min] = NULL;
+
+ // Also eliminate the caches for large glyphs, as they consume significant memory
+ for (int i = 0; i < kGammaCount; ++i) {
+ if (mRenderers[i]) {
+ mRenderers[i]->flushLargeCaches();
+ }
+ }
}
FontRenderer* GammaFontRenderer::getRenderer(Gamma gamma) {