From 5603b71328cbcd9ab244404be6f8eda94eb9adcd Mon Sep 17 00:00:00 2001 From: Billy Lam Date: Tue, 18 Jul 2017 12:01:44 -0700 Subject: [PATCH] GC in heapDumpFinished to cleanup hprof fd Previously the fd associated with the dump file was not closed until the next GC. While this did not affect AMS, external systems relying on monitoring the close event on the file could not accurately know when a dump operation was finished. Bug: 62907010 Test: Manually flashed and tested Change-Id: I0f6988099f479468f674eb7483f1f14529852270 --- .../java/com/android/server/am/ActivityManagerService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 784a7104bba4f..867a7cbe6b490 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -21767,6 +21767,9 @@ public final class ActivityManagerService extends ActivityManagerNative } if (DEBUG_PSS) Slog.d(TAG_PSS, "Dump heap finished for " + path); mHandler.sendEmptyMessage(POST_DUMP_HEAP_NOTIFICATION_MSG); + + // Forced gc to clean up the remnant hprof fd. + Runtime.getRuntime().gc(); } }