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

Commit 439e654f authored by Martijn Coenen's avatar Martijn Coenen Committed by Automerger Merge Worker
Browse files

Merge "Run a GC after killing a UID due to binder proxy limit." into sc-qpr1-dev am: 745bc362

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15889363

Change-Id: Ic202efe6cf40dda3a0bd25c68e133f1d9405aa6b
parents 44dfbe56 745bc362
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -74,7 +74,7 @@ public final class BinderProxy implements IBinder {
        private static final int MAIN_INDEX_SIZE = 1 <<  LOG_MAIN_INDEX_SIZE;
        private static final int MAIN_INDEX_SIZE = 1 <<  LOG_MAIN_INDEX_SIZE;
        private static final int MAIN_INDEX_MASK = MAIN_INDEX_SIZE - 1;
        private static final int MAIN_INDEX_MASK = MAIN_INDEX_SIZE - 1;
        // Debuggable builds will throw an AssertionError if the number of map entries exceeds:
        // Debuggable builds will throw an AssertionError if the number of map entries exceeds:
        private static final int CRASH_AT_SIZE = 20_000;
        private static final int CRASH_AT_SIZE = 25_000;


        /**
        /**
         * We next warn when we exceed this bucket size.
         * We next warn when we exceed this bucket size.
+11 −0
Original line number Original line Diff line number Diff line
@@ -7736,6 +7736,17 @@ public class ActivityManagerService extends IActivityManager.Stub
                        } else {
                        } else {
                            killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid),
                            killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid),
                                    "Too many Binders sent to SYSTEM");
                                    "Too many Binders sent to SYSTEM");
                            // We need to run a GC here, because killing the processes involved
                            // actually isn't guaranteed to free up the proxies; in fact, if the
                            // GC doesn't run for a long time, we may even exceed the global
                            // proxy limit for a process (20000), resulting in system_server itself
                            // being killed.
                            // Note that the GC here might not actually clean up all the proxies,
                            // because the binder reference decrements will come in asynchronously;
                            // but if new processes belonging to the UID keep adding proxies, we
                            // will get another callback here, and run the GC again - this time
                            // cleaning up the old proxies.
                            VMRuntime.getRuntime().requestConcurrentGC();
                        }
                        }
                    }, mHandler);
                    }, mHandler);
            t.traceEnd(); // setBinderProxies
            t.traceEnd(); // setBinderProxies