Trim graphics memory when closing the shade
Graphics memory usually gets trimmed in applications when the
activity goes into the background. We use quite a lot of graphics
memory when the shade/lockscreen is open, and some of them never gets
freed unless the recents activity is closed, because we don't have
these activity-trimming-heuristics for the shade. This change
proactively trims the graphics memory when the shade gets closed or
when the lockscreen is hidden, to emulate the same heuristics as for
activities.
This change also adds trimMemory on RenderThread to systrace to
verify that no jank is introduced with this change.
This change immediately saves around 10-30 MB on an xxhdpi device
after the shade is closed.
Bug: 17581375
Change-Id: I4fb622efb51815fe08187be97ba15d012d4de5d4
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index b50a433..3bb4778 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -330,6 +330,7 @@
// No context means nothing to free
if (!thread.eglManager().hasEglContext()) return;
+ ATRACE_CALL();
thread.eglManager().requireGlContext();
if (level >= TRIM_MEMORY_COMPLETE) {
Caches::getInstance().flush(Caches::kFlushMode_Full);