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

Commit cf1bffaa authored by Miguel Aranda's avatar Miguel Aranda
Browse files

Allow explicit GC usage for StrictMode setClassInstanceLimit

This wraps the calls to System.GC() in a disabling of the explicit gc checks from another strict mode so that those calls do not produce a crash when SetClassInstanceLimit is used.

Change-Id: I54d2ff975838e3f54879de3fbff25614137b31df
Test: atest testClassInstanceLimit
Bug: 305288285
parent b0e4f7e7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2023,9 +2023,13 @@ public final class StrictMode {
            return;
        }

        // Temporarily disable checks so that explicit GC is allowed.
        final int oldMask = getThreadPolicyMask();
        setThreadPolicyMask(0);
        System.gc();
        System.runFinalization();
        System.gc();
        setThreadPolicyMask(oldMask);

        // Note: classInstanceLimit is immutable, so this is lock-free
        // Create the classes array.