diff options
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1f6334381bc9..13fd0eaa6f71 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -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(); |