OSDN Git Service

GC in heapDumpFinished to cleanup hprof fd
authorBilly Lam <shiufai@google.com>
Tue, 18 Jul 2017 19:01:44 +0000 (12:01 -0700)
committerBilly Lam <shiufai@google.com>
Tue, 18 Jul 2017 20:37:57 +0000 (13:37 -0700)
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

services/core/java/com/android/server/am/ActivityManagerService.java

index 784a710..867a7cb 100644 (file)
@@ -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();
         }
     }