Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c5e78e2 authored by Eric Miao's avatar Eric Miao Committed by Android (Google) Code Review
Browse files

Merge "Report post-GC memory metrics for system_server" into main

parents ab0b344a cf863c31
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class MetricsLoggerWrapper {
            return;
        }
        int pid = Process.myPid();
        String processName = Application.getProcessName();
        String processName = Process.myProcessName();
        Collection<NativeAllocationRegistry.Metrics> metrics =
            NativeAllocationRegistry.getMetrics();
        int nMetrics = metrics.size();
+12 −0
Original line number Diff line number Diff line
@@ -109,6 +109,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;
@@ -1002,6 +1003,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");