Further MemoryTracker robustness:

- grab a copy of the tracked processes list in the dumper
- scan running processes when memorytracker starts to catch
  pids that may have survived a crash of the tracker's process
- use RunningServiceInfo to figure out roughly how long a
  service scanned in this way has been alive

Change-Id: I861642f07183e3945f7a7a41e1e5144567e17e13
This commit is contained in:
Daniel Sandler
2013-07-07 17:16:49 -05:00
parent a29949d2ef
commit 0adfc5a755
3 changed files with 32 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ import android.util.Log;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -85,7 +86,9 @@ public class MemoryDumpActivity extends Activity {
final ArrayList<String> paths = new ArrayList<String>();
final int myPid = android.os.Process.myPid();
for (int pid : tracker.getTrackedProcesses()) {
final int[] pids_orig = tracker.getTrackedProcesses();
final int[] pids_copy = Arrays.copyOf(pids_orig, pids_orig.length);
for (int pid : pids_copy) {
MemoryTracker.ProcessMemInfo info = tracker.getMemInfo(pid);
if (info != null) {
body.append("pid ").append(pid).append(":")