Merge "Implement dumpheap -m."
This commit is contained in:
committed by
Android (Google) Code Review
commit
f003ae0f25
@@ -658,6 +658,8 @@ public final class ActivityThread {
|
||||
}
|
||||
|
||||
static final class DumpHeapData {
|
||||
public boolean managed;
|
||||
public boolean mallocInfo;
|
||||
public boolean runGc;
|
||||
String path;
|
||||
ParcelFileDescriptor fd;
|
||||
@@ -1025,12 +1027,15 @@ public final class ActivityThread {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpHeap(boolean managed, boolean runGc, String path, ParcelFileDescriptor fd) {
|
||||
public void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, String path,
|
||||
ParcelFileDescriptor fd) {
|
||||
DumpHeapData dhd = new DumpHeapData();
|
||||
dhd.managed = managed;
|
||||
dhd.mallocInfo = mallocInfo;
|
||||
dhd.runGc = runGc;
|
||||
dhd.path = path;
|
||||
dhd.fd = fd;
|
||||
sendMessage(H.DUMP_HEAP, dhd, managed ? 1 : 0, 0, true /*async*/);
|
||||
sendMessage(H.DUMP_HEAP, dhd, 0, 0, true /*async*/);
|
||||
}
|
||||
|
||||
public void attachAgent(String agent) {
|
||||
@@ -1762,7 +1767,7 @@ public final class ActivityThread {
|
||||
case SCHEDULE_CRASH:
|
||||
throw new RemoteServiceException((String)msg.obj);
|
||||
case DUMP_HEAP:
|
||||
handleDumpHeap(msg.arg1 != 0, (DumpHeapData)msg.obj);
|
||||
handleDumpHeap((DumpHeapData) msg.obj);
|
||||
break;
|
||||
case DUMP_ACTIVITY:
|
||||
handleDumpActivity((DumpComponentInfo)msg.obj);
|
||||
@@ -5173,13 +5178,13 @@ public final class ActivityThread {
|
||||
}
|
||||
}
|
||||
|
||||
static final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
|
||||
static void handleDumpHeap(DumpHeapData dhd) {
|
||||
if (dhd.runGc) {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.gc();
|
||||
}
|
||||
if (managed) {
|
||||
if (dhd.managed) {
|
||||
try {
|
||||
Debug.dumpHprofData(dhd.path, dhd.fd.getFileDescriptor());
|
||||
} catch (IOException e) {
|
||||
@@ -5192,6 +5197,8 @@ public final class ActivityThread {
|
||||
Slog.w(TAG, "Failure closing profile fd", e);
|
||||
}
|
||||
}
|
||||
} else if (dhd.mallocInfo) {
|
||||
Debug.dumpNativeMallocInfo(dhd.fd.getFileDescriptor());
|
||||
} else {
|
||||
Debug.dumpNativeHeap(dhd.fd.getFileDescriptor());
|
||||
}
|
||||
|
||||
@@ -277,8 +277,8 @@ interface IActivityManager {
|
||||
int checkGrantUriPermission(int callingUid, in String targetPkg, in Uri uri,
|
||||
int modeFlags, int userId);
|
||||
// Cause the specified process to dump the specified heap.
|
||||
boolean dumpHeap(in String process, int userId, boolean managed, boolean runGc, in String path,
|
||||
in ParcelFileDescriptor fd);
|
||||
boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo,
|
||||
boolean runGc, in String path, in ParcelFileDescriptor fd);
|
||||
int startActivities(in IApplicationThread caller, in String callingPackage,
|
||||
in Intent[] intents, in String[] resolvedTypes, in IBinder resultTo,
|
||||
in Bundle options, int userId);
|
||||
|
||||
@@ -117,7 +117,8 @@ oneway interface IApplicationThread {
|
||||
void scheduleSuicide();
|
||||
void dispatchPackageBroadcast(int cmd, in String[] packages);
|
||||
void scheduleCrash(in String msg);
|
||||
void dumpHeap(boolean managed, boolean runGc, in String path, in ParcelFileDescriptor fd);
|
||||
void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, in String path,
|
||||
in ParcelFileDescriptor fd);
|
||||
void dumpActivity(in ParcelFileDescriptor fd, IBinder servicetoken, in String prefix,
|
||||
in String[] args);
|
||||
void clearDnsCache();
|
||||
|
||||
@@ -1813,6 +1813,13 @@ public final class Debug
|
||||
*/
|
||||
public static native void dumpNativeHeap(FileDescriptor fd);
|
||||
|
||||
/**
|
||||
* Writes malloc info data to the specified file descriptor.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static native void dumpNativeMallocInfo(FileDescriptor fd);
|
||||
|
||||
/**
|
||||
* Returns a count of the extant instances of a class.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user