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

Commit a63cd9f4 authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge "Run finalizers before counting for StrictMode." into klp-modular-dev

parents c01e1aeb 9c5c56eb
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1449,7 +1449,11 @@ public final class StrictMode {
        if (policy.classInstanceLimit.size() == 0) {
            return;
        }
        Runtime.getRuntime().gc();

        System.gc();
        System.runFinalization();
        System.gc();

        // Note: classInstanceLimit is immutable, so this is lock-free
        for (Map.Entry<Class, Integer> entry : policy.classInstanceLimit.entrySet()) {
            Class klass = entry.getKey();
@@ -2005,7 +2009,10 @@ public final class StrictMode {
        // noticeably less responsive during orientation changes when activities are
        // being restarted.  Granted, it is only a problem when StrictMode is enabled
        // but it is annoying.
        Runtime.getRuntime().gc();

        System.gc();
        System.runFinalization();
        System.gc();

        long instances = VMDebug.countInstancesOfClass(klass, false);
        if (instances > limit) {