Add trimMemory level to traces

Test: Manual
Change-Id: I5cadea92f80f7ff8fa549a5917146a405d0808a3
This commit is contained in:
Zim
2022-11-24 20:23:55 +00:00
parent a3d6ae1031
commit 5e5e215cb5

View File

@@ -6378,23 +6378,28 @@ public final class ActivityThread extends ClientTransactionHandler
}
private void handleTrimMemory(int level) {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "trimMemory");
if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "trimMemory: " + level);
}
if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Trimming memory to level: " + level);
if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
PropertyInvalidatedCache.onTrimMemory();
}
try {
if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
PropertyInvalidatedCache.onTrimMemory();
}
final ArrayList<ComponentCallbacks2> callbacks =
collectComponentCallbacks(true /* includeUiContexts */);
final ArrayList<ComponentCallbacks2> callbacks =
collectComponentCallbacks(true /* includeUiContexts */);
final int N = callbacks.size();
for (int i = 0; i < N; i++) {
callbacks.get(i).onTrimMemory(level);
final int N = callbacks.size();
for (int i = 0; i < N; i++) {
callbacks.get(i).onTrimMemory(level);
}
} finally {
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
}
WindowManagerGlobal.getInstance().trimMemory(level);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
if (SystemProperties.getInt("debug.am.run_gc_trim_level", Integer.MAX_VALUE) <= level) {
unscheduleGcIdler();