From 6a5274513a1fbbf728bf81caf09184d1233d554a Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Thu, 8 Jul 2021 17:21:20 -0700 Subject: [PATCH] Add System.runFinalization() call Lone calls to System.gc() generally don't do anything. Runtime.getRuntime().gc() would force a GC, but it would be ineffective without waiting for reference processing and finalization to complete. Adding the runFinalization() call implicitly makes the preceding GC call effective. Bug: 183912710 Test: Treehugger Change-Id: I0f4806b8e3f9ca898eb7ea1b1c8de14aa94e2646 Merged-In: I0f4806b8e3f9ca898eb7ea1b1c8de14aa94e2646 --- services/java/com/android/server/SystemServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index d487483cfb564..91d4f7e2a24de 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -552,6 +552,7 @@ public final class SystemServer implements Dumpable { if (maxFd > enableThreshold) { // Do a manual GC to clean up fds that are hanging around as garbage. System.gc(); + System.runFinalization(); maxFd = getMaxFd(); }