summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zim <zezeozue@google.com> 2022-11-24 20:23:55 +0000
committer Zim <zezeozue@google.com> 2022-11-25 15:14:16 +0000
commit5e5e215cb540ebae76cab88d2fd6d3a1efb5188b (patch)
tree529dc2b20d6e02a0a73d74a009fcf4f8b9d1cfd3
parenta3d6ae1031e51bf8083f13ad8656f1fafafd2892 (diff)
Add trimMemory level to traces
Test: Manual Change-Id: I5cadea92f80f7ff8fa549a5917146a405d0808a3
-rw-r--r--core/java/android/app/ActivityThread.java25
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();