Enable fdtrack in system_server.

Spawn a thread that monitors the current fd count, and enables fdtrack
to hunt down leaks when it gets too high.

Bug: http://b/140703823
Test: setprop persist.sys.debug.fdtrack_enable_threshold; stop; start; logcat -c; killall -39 system_server; logcat -d | grep fdtrack
Change-Id: If5831f57d47e6958112abced181f07e18e6a7261
This commit is contained in:
Josh Gao
2019-12-05 16:41:59 -08:00
parent 88d4019b82
commit 679f3e4242
2 changed files with 69 additions and 1 deletions

View File

@@ -353,6 +353,12 @@ public final class SystemServer {
*/
private static native void initZygoteChildHeapProfiling();
/**
* Spawn a thread that monitors for fd leaks.
*/
private static native void spawnFdLeakCheckThread();
/**
* The main entry point from zygote.
*/
@@ -484,6 +490,11 @@ public final class SystemServer {
initZygoteChildHeapProfiling();
}
// Debug builds - spawn a thread to monitor for fd leaks.
if (Build.IS_DEBUGGABLE) {
spawnFdLeakCheckThread();
}
// Check whether we failed to shut down last time we tried.
// This call may not return.
performPendingShutdown();