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

Commit 9ee9bd26 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not report native memory metrics for instrumentation

If the instrumentation info is not null, that means the process
is running test cases. That isn't a regular use case.

Additionally, if the test case is performing static mocking
(StaticMockMethodAdvice), it may hit concurrent accesses exception.

Bug: 331243037
Flag: EXEMPT TEST_ONLY
Test: Run tests with static mock.
Change-Id: I128c76ce4890189d9d51d544e567e0129403b578
parent fe243d08
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -7831,9 +7831,10 @@ public final class ActivityThread extends ClientTransactionHandler

        // Register callback to report native memory metrics post GC cleanup
        // Note: we do not report memory metrics of isolated processes unless
        // their native allocations become more significant
        if (!Process.isIsolated() && Flags.reportPostgcMemoryMetrics() &&
            com.android.libcore.readonly.Flags.postCleanupApis()) {
        // their native allocations become more significant. Instrumentation is
        // also excluded because the metrics from test cases are not meaningful.
        if (!Process.isIsolated() && ii == null && Flags.reportPostgcMemoryMetrics()
                && com.android.libcore.readonly.Flags.postCleanupApis()) {
            VMRuntime.addPostCleanupCallback(new Runnable() {
                @Override public void run() {
                    MetricsLoggerWrapper.logPostGcMemorySnapshot();