diff options
author | 2024-12-10 15:43:58 -0800 | |
---|---|---|
committer | 2024-12-12 09:53:52 -0800 | |
commit | cf863c31e863bc01c5219554583e32501e55394e (patch) | |
tree | b66afd6271ccb829478a0e9155c4d115503f257a /services/java | |
parent | 512e4239dd3bbd55943bb786b1d41eb2fb0367a7 (diff) |
Report post-GC memory metrics for system_server
Currently, applications register their callbacks to report post-GC
memory metrics in ActivityThread.handleBindApplication. This however
does not apply to system_server. This CL registers the callbacks
specifically for system_server to report the post-GC memory metrics.
Also, change to use `Process.myProcessName()` for the process name
as `Application.getProcessName()` does not work for system_server.
Bug: 382022031
Flag: android.app.report_postgc_memory_metrics
Change-Id: If3345d9db4ce26743d39b0a17c9092ce23b7ffcd
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/SystemServer.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 3805c02d1bb9..a82b38277b16 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -107,6 +107,7 @@ import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.ApplicationSharedMemory; import com.android.internal.os.BinderInternal; import com.android.internal.os.RuntimeInit; +import com.android.internal.os.logging.MetricsLoggerWrapper; import com.android.internal.pm.RoSystemFeatures; import com.android.internal.policy.AttributeCache; import com.android.internal.protolog.ProtoLog; @@ -991,6 +992,17 @@ public final class SystemServer implements Dumpable { } }); + // Register callback to report native memory metrics post GC cleanup + // for system_server + if (android.app.Flags.reportPostgcMemoryMetrics() && + com.android.libcore.readonly.Flags.postCleanupApis()) { + VMRuntime.addPostCleanupCallback(new Runnable() { + @Override public void run() { + MetricsLoggerWrapper.logPostGcMemorySnapshot(); + } + }); + } + // Loop forever. Looper.loop(); throw new RuntimeException("Main thread loop unexpectedly exited"); |