Program: 295
Project: 295
Buggy source:
final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,String prefix,String[] args,boolean brief,PrintWriter categoryPw){
  boolean dumpDetails=false;
  boolean dumpFullDetails=false;
  boolean dumpDalvik=false;
  boolean oomOnly=false;
  boolean isCompact=false;
  int opti=0;
  while (opti < args.length) {
    String opt=args[opti];
    if (opt == null || opt.length() <= 0 || opt.charAt(0) != '-') {
      break;
    }
    opti++;
    if ("String_Node_Str".equals(opt)) {
      dumpDetails=true;
      dumpFullDetails=true;
      dumpDalvik=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      dumpDalvik=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      isCompact=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      oomOnly=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      return;
    }
 else {
      pw.println("String_Node_Str" + opt + "String_Node_Str");
    }
  }
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  final long[] tmpLong=new long[1];
  ArrayList<ProcessRecord> procs=collectProcesses(pw,opti,args);
  if (procs == null) {
    if (args != null && args.length > opti && args[opti].charAt(0) != '-') {
      ArrayList<ProcessCpuTracker.Stats> nativeProcs=new ArrayList<ProcessCpuTracker.Stats>();
      updateCpuStatsNow();
      int findPid=-1;
      try {
        findPid=Integer.parseInt(args[opti]);
      }
 catch (      NumberFormatException e) {
      }
synchronized (mProcessCpuThread) {
        final int N=mProcessCpuTracker.countStats();
        for (int i=0; i < N; i++) {
          ProcessCpuTracker.Stats st=mProcessCpuTracker.getStats(i);
          if (st.pid == findPid || (st.baseName != null && st.baseName.equals(args[opti]))) {
            nativeProcs.add(st);
          }
        }
      }
      if (nativeProcs.size() > 0) {
        dumpApplicationMemoryUsageHeader(pw,uptime,realtime,isCheckinRequest,isCompact);
        Debug.MemoryInfo mi=null;
        for (int i=nativeProcs.size() - 1; i >= 0; i--) {
          final ProcessCpuTracker.Stats r=nativeProcs.get(i);
          final int pid=r.pid;
          if (!isCheckinRequest && dumpDetails) {
            pw.println("String_Node_Str" + pid + "String_Node_Str"+ r.baseName+ "String_Node_Str");
          }
          if (mi == null) {
            mi=new Debug.MemoryInfo();
          }
          if (dumpDetails || (!brief && !oomOnly)) {
            Debug.getMemoryInfo(pid,mi);
          }
 else {
            mi.dalvikPss=(int)Debug.getPss(pid,tmpLong);
            mi.dalvikPrivateDirty=(int)tmpLong[0];
          }
          ActivityThread.dumpMemInfoTable(pw,mi,isCheckinRequest,dumpFullDetails,dumpDalvik,pid,r.baseName,0,0,0,0,0,0);
          if (isCheckinRequest) {
            pw.println();
          }
        }
        return;
      }
    }
    pw.println("String_Node_Str" + args[opti]);
    return;
  }
  if (!brief && !oomOnly && (procs.size() == 1 || isCheckinRequest)) {
    dumpDetails=true;
  }
  dumpApplicationMemoryUsageHeader(pw,uptime,realtime,isCheckinRequest,isCompact);
  String[] innerArgs=new String[args.length - opti];
  System.arraycopy(args,opti,innerArgs,0,args.length - opti);
  ArrayList<MemItem> procMems=new ArrayList<MemItem>();
  final SparseArray<MemItem> procMemsMap=new SparseArray<MemItem>();
  long nativePss=0, dalvikPss=0, otherPss=0;
  long[] miscPss=new long[Debug.MemoryInfo.NUM_OTHER_STATS];
  long oomPss[]=new long[DUMP_MEM_OOM_LABEL.length];
  ArrayList<MemItem>[] oomProcs=(ArrayList<MemItem>[])new ArrayList[DUMP_MEM_OOM_LABEL.length];
  long totalPss=0;
  long cachedPss=0;
  Debug.MemoryInfo mi=null;
  for (int i=procs.size() - 1; i >= 0; i--) {
    final ProcessRecord r=procs.get(i);
    final IApplicationThread thread;
    final int pid;
    final int oomAdj;
    final boolean hasActivities;
synchronized (this) {
      thread=r.thread;
      pid=r.pid;
      oomAdj=r.getSetAdjWithServices();
      hasActivities=r.activities.size() > 0;
    }
    if (thread != null) {
      if (!isCheckinRequest && dumpDetails) {
        pw.println("String_Node_Str" + pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
      }
      if (mi == null) {
        mi=new Debug.MemoryInfo();
      }
      if (dumpDetails || (!brief && !oomOnly)) {
        Debug.getMemoryInfo(pid,mi);
      }
 else {
        mi.dalvikPss=(int)Debug.getPss(pid,tmpLong);
        mi.dalvikPrivateDirty=(int)tmpLong[0];
      }
      if (dumpDetails) {
        try {
          pw.flush();
          thread.dumpMemInfo(fd,mi,isCheckinRequest,dumpFullDetails,dumpDalvik,innerArgs);
        }
 catch (        RemoteException e) {
          if (!isCheckinRequest) {
            pw.println("String_Node_Str");
            pw.flush();
          }
        }
      }
      final long myTotalPss=mi.getTotalPss();
      final long myTotalUss=mi.getTotalUss();
synchronized (this) {
        if (r.thread != null && oomAdj == r.getSetAdjWithServices()) {
          r.baseProcessTracker.addPss(myTotalPss,myTotalUss,true,r.pkgList);
        }
      }
      if (!isCheckinRequest && mi != null) {
        totalPss+=myTotalPss;
        MemItem pssItem=new MemItem(r.processName + "String_Node_Str" + pid+ (hasActivities ? "String_Node_Str" : "String_Node_Str"),r.processName,myTotalPss,pid,hasActivities);
        procMems.add(pssItem);
        procMemsMap.put(pid,pssItem);
        nativePss+=mi.nativePss;
        dalvikPss+=mi.dalvikPss;
        otherPss+=mi.otherPss;
        for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
          long mem=mi.getOtherPss(j);
          miscPss[j]+=mem;
          otherPss-=mem;
        }
        if (oomAdj >= ProcessList.CACHED_APP_MIN_ADJ) {
          cachedPss+=myTotalPss;
        }
        for (int oomIndex=0; oomIndex < oomPss.length; oomIndex++) {
          if (oomAdj <= DUMP_MEM_OOM_ADJ[oomIndex] || oomIndex == (oomPss.length - 1)) {
            oomPss[oomIndex]+=myTotalPss;
            if (oomProcs[oomIndex] == null) {
              oomProcs[oomIndex]=new ArrayList<MemItem>();
            }
            oomProcs[oomIndex].add(pssItem);
            break;
          }
        }
      }
    }
  }
  if (!isCheckinRequest && procs.size() > 1) {
    updateCpuStatsNow();
synchronized (mProcessCpuThread) {
      final int N=mProcessCpuTracker.countStats();
      for (int i=0; i < N; i++) {
        ProcessCpuTracker.Stats st=mProcessCpuTracker.getStats(i);
        if (st.vsize > 0 && procMemsMap.indexOfKey(st.pid) < 0) {
          if (mi == null) {
            mi=new Debug.MemoryInfo();
          }
          if (!brief && !oomOnly) {
            Debug.getMemoryInfo(st.pid,mi);
          }
 else {
            mi.nativePss=(int)Debug.getPss(st.pid,tmpLong);
            mi.nativePrivateDirty=(int)tmpLong[0];
          }
          final long myTotalPss=mi.getTotalPss();
          totalPss+=myTotalPss;
          MemItem pssItem=new MemItem(st.name + "String_Node_Str" + st.pid+ "String_Node_Str",st.name,myTotalPss,st.pid,false);
          procMems.add(pssItem);
          nativePss+=mi.nativePss;
          dalvikPss+=mi.dalvikPss;
          otherPss+=mi.otherPss;
          for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
            long mem=mi.getOtherPss(j);
            miscPss[j]+=mem;
            otherPss-=mem;
          }
          oomPss[0]+=myTotalPss;
          if (oomProcs[0] == null) {
            oomProcs[0]=new ArrayList<MemItem>();
          }
          oomProcs[0].add(pssItem);
        }
      }
    }
    ArrayList<MemItem> catMems=new ArrayList<MemItem>();
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",nativePss,-1));
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",dalvikPss,-2));
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",otherPss,-3));
    for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
      String label=Debug.MemoryInfo.getOtherLabel(j);
      catMems.add(new MemItem(label,label,miscPss[j],j));
    }
    ArrayList<MemItem> oomMems=new ArrayList<MemItem>();
    for (int j=0; j < oomPss.length; j++) {
      if (oomPss[j] != 0) {
        String label=isCompact ? DUMP_MEM_OOM_COMPACT_LABEL[j] : DUMP_MEM_OOM_LABEL[j];
        MemItem item=new MemItem(label,label,oomPss[j],DUMP_MEM_OOM_ADJ[j]);
        item.subitems=oomProcs[j];
        oomMems.add(item);
      }
    }
    if (!brief && !oomOnly && !isCompact) {
      pw.println();
      pw.println("String_Node_Str");
      dumpMemItems(pw,"String_Node_Str","String_Node_Str",procMems,true,isCompact);
      pw.println();
    }
    if (!isCompact) {
      pw.println("String_Node_Str");
    }
    dumpMemItems(pw,"String_Node_Str","String_Node_Str",oomMems,false,isCompact);
    if (!brief && !oomOnly) {
      PrintWriter out=categoryPw != null ? categoryPw : pw;
      if (!isCompact) {
        out.println();
        out.println("String_Node_Str");
      }
      dumpMemItems(out,"String_Node_Str","String_Node_Str",catMems,true,isCompact);
    }
    if (!isCompact) {
      pw.println();
    }
    MemInfoReader memInfo=new MemInfoReader();
    memInfo.readMemInfo();
    if (!brief) {
      if (!isCompact) {
        pw.print("String_Node_Str");
        pw.print(memInfo.getTotalSizeKb());
        pw.println("String_Node_Str");
        pw.print("String_Node_Str");
        pw.print(cachedPss + memInfo.getCachedSizeKb() + memInfo.getFreeSizeKb());
        pw.print("String_Node_Str");
        pw.print(cachedPss);
        pw.print("String_Node_Str");
        pw.print(memInfo.getCachedSizeKb());
        pw.print("String_Node_Str");
        pw.print(memInfo.getFreeSizeKb());
        pw.println("String_Node_Str");
      }
 else {
        pw.print("String_Node_Str");
        pw.print(memInfo.getTotalSizeKb());
        pw.print("String_Node_Str");
        pw.print(cachedPss + memInfo.getCachedSizeKb() + memInfo.getFreeSizeKb());
        pw.print("String_Node_Str");
        pw.println(totalPss - cachedPss);
      }
    }
    if (!isCompact) {
      pw.print("String_Node_Str");
      pw.print(totalPss - cachedPss + memInfo.getBuffersSizeKb() + memInfo.getShmemSizeKb() + memInfo.getSlabSizeKb());
      pw.print("String_Node_Str");
      pw.print(totalPss - cachedPss);
      pw.print("String_Node_Str");
      pw.print(memInfo.getBuffersSizeKb());
      pw.print("String_Node_Str");
      pw.print(memInfo.getShmemSizeKb());
      pw.print("String_Node_Str");
      pw.print(memInfo.getSlabSizeKb());
      pw.println("String_Node_Str");
      pw.print("String_Node_Str");
      pw.print(memInfo.getTotalSizeKb() - totalPss - memInfo.getFreeSizeKb()- memInfo.getCachedSizeKb()- memInfo.getBuffersSizeKb()- memInfo.getShmemSizeKb()- memInfo.getSlabSizeKb());
      pw.println("String_Node_Str");
    }
    if (!brief) {
      if (memInfo.getZramTotalSizeKb() != 0) {
        if (!isCompact) {
          pw.print("String_Node_Str");
          pw.print(memInfo.getZramTotalSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb() - memInfo.getSwapFreeSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb());
          pw.println("String_Node_Str");
        }
 else {
          pw.print("String_Node_Str");
          pw.print(memInfo.getZramTotalSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb());
          pw.print("String_Node_Str");
          pw.println(memInfo.getSwapFreeSizeKb());
        }
      }
      final int[] SINGLE_LONG_FORMAT=new int[]{Process.PROC_SPACE_TERM | Process.PROC_OUT_LONG};
      long[] longOut=new long[1];
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long shared=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long sharing=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long unshared=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long voltile=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      if (!isCompact) {
        if (sharing != 0 || shared != 0 || unshared != 0 || voltile != 0) {
          pw.print("String_Node_Str");
          pw.print(sharing);
          pw.print("String_Node_Str");
          pw.print(shared);
          pw.println("String_Node_Str");
          pw.print("String_Node_Str");
          pw.print(unshared);
          pw.print("String_Node_Str");
          pw.print(voltile);
          pw.println("String_Node_Str");
        }
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetMemoryClass());
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetLargeMemoryClass());
        pw.print("String_Node_Str");
        pw.print(mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024);
        pw.print("String_Node_Str");
        pw.print("String_Node_Str");
        pw.print(mProcessList.getCachedRestoreThresholdKb());
        pw.print("String_Node_Str");
        if (ActivityManager.isLowRamDeviceStatic()) {
          pw.print("String_Node_Str");
        }
        if (ActivityManager.isHighEndGfx()) {
          pw.print("String_Node_Str");
        }
        pw.println();
      }
 else {
        pw.print("String_Node_Str");
        pw.print(sharing);
        pw.print("String_Node_Str");
        pw.print(shared);
        pw.print("String_Node_Str");
        pw.print(unshared);
        pw.print("String_Node_Str");
        pw.println(voltile);
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetMemoryClass());
        pw.print(',');
        pw.print(ActivityManager.staticGetLargeMemoryClass());
        pw.print(',');
        pw.print(mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024);
        if (ActivityManager.isLowRamDeviceStatic()) {
          pw.print("String_Node_Str");
        }
        if (ActivityManager.isHighEndGfx()) {
          pw.print("String_Node_Str");
        }
        pw.println();
      }
    }
  }
}

Fixed version (ground truth):
final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,String prefix,String[] args,boolean brief,PrintWriter categoryPw){
  boolean dumpDetails=false;
  boolean dumpFullDetails=false;
  boolean dumpDalvik=false;
  boolean oomOnly=false;
  boolean isCompact=false;
  boolean localOnly=false;
  int opti=0;
  while (opti < args.length) {
    String opt=args[opti];
    if (opt == null || opt.length() <= 0 || opt.charAt(0) != '-') {
      break;
    }
    opti++;
    if ("String_Node_Str".equals(opt)) {
      dumpDetails=true;
      dumpFullDetails=true;
      dumpDalvik=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      dumpDalvik=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      isCompact=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      oomOnly=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      localOnly=true;
    }
 else     if ("String_Node_Str".equals(opt)) {
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      pw.println("String_Node_Str");
      return;
    }
 else {
      pw.println("String_Node_Str" + opt + "String_Node_Str");
    }
  }
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  final long[] tmpLong=new long[1];
  ArrayList<ProcessRecord> procs=collectProcesses(pw,opti,args);
  if (procs == null) {
    if (args != null && args.length > opti && args[opti].charAt(0) != '-') {
      ArrayList<ProcessCpuTracker.Stats> nativeProcs=new ArrayList<ProcessCpuTracker.Stats>();
      updateCpuStatsNow();
      int findPid=-1;
      try {
        findPid=Integer.parseInt(args[opti]);
      }
 catch (      NumberFormatException e) {
      }
synchronized (mProcessCpuThread) {
        final int N=mProcessCpuTracker.countStats();
        for (int i=0; i < N; i++) {
          ProcessCpuTracker.Stats st=mProcessCpuTracker.getStats(i);
          if (st.pid == findPid || (st.baseName != null && st.baseName.equals(args[opti]))) {
            nativeProcs.add(st);
          }
        }
      }
      if (nativeProcs.size() > 0) {
        dumpApplicationMemoryUsageHeader(pw,uptime,realtime,isCheckinRequest,isCompact);
        Debug.MemoryInfo mi=null;
        for (int i=nativeProcs.size() - 1; i >= 0; i--) {
          final ProcessCpuTracker.Stats r=nativeProcs.get(i);
          final int pid=r.pid;
          if (!isCheckinRequest && dumpDetails) {
            pw.println("String_Node_Str" + pid + "String_Node_Str"+ r.baseName+ "String_Node_Str");
          }
          if (mi == null) {
            mi=new Debug.MemoryInfo();
          }
          if (dumpDetails || (!brief && !oomOnly)) {
            Debug.getMemoryInfo(pid,mi);
          }
 else {
            mi.dalvikPss=(int)Debug.getPss(pid,tmpLong);
            mi.dalvikPrivateDirty=(int)tmpLong[0];
          }
          ActivityThread.dumpMemInfoTable(pw,mi,isCheckinRequest,dumpFullDetails,dumpDalvik,pid,r.baseName,0,0,0,0,0,0);
          if (isCheckinRequest) {
            pw.println();
          }
        }
        return;
      }
    }
    pw.println("String_Node_Str" + args[opti]);
    return;
  }
  if (!brief && !oomOnly && (procs.size() == 1 || isCheckinRequest)) {
    dumpDetails=true;
  }
  dumpApplicationMemoryUsageHeader(pw,uptime,realtime,isCheckinRequest,isCompact);
  String[] innerArgs=new String[args.length - opti];
  System.arraycopy(args,opti,innerArgs,0,args.length - opti);
  ArrayList<MemItem> procMems=new ArrayList<MemItem>();
  final SparseArray<MemItem> procMemsMap=new SparseArray<MemItem>();
  long nativePss=0, dalvikPss=0, otherPss=0;
  long[] miscPss=new long[Debug.MemoryInfo.NUM_OTHER_STATS];
  long oomPss[]=new long[DUMP_MEM_OOM_LABEL.length];
  ArrayList<MemItem>[] oomProcs=(ArrayList<MemItem>[])new ArrayList[DUMP_MEM_OOM_LABEL.length];
  long totalPss=0;
  long cachedPss=0;
  Debug.MemoryInfo mi=null;
  for (int i=procs.size() - 1; i >= 0; i--) {
    final ProcessRecord r=procs.get(i);
    final IApplicationThread thread;
    final int pid;
    final int oomAdj;
    final boolean hasActivities;
synchronized (this) {
      thread=r.thread;
      pid=r.pid;
      oomAdj=r.getSetAdjWithServices();
      hasActivities=r.activities.size() > 0;
    }
    if (thread != null) {
      if (!isCheckinRequest && dumpDetails) {
        pw.println("String_Node_Str" + pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
      }
      if (mi == null) {
        mi=new Debug.MemoryInfo();
      }
      if (dumpDetails || (!brief && !oomOnly)) {
        Debug.getMemoryInfo(pid,mi);
      }
 else {
        mi.dalvikPss=(int)Debug.getPss(pid,tmpLong);
        mi.dalvikPrivateDirty=(int)tmpLong[0];
      }
      if (dumpDetails) {
        if (localOnly) {
          ActivityThread.dumpMemInfoTable(pw,mi,isCheckinRequest,dumpFullDetails,dumpDalvik,pid,r.processName,0,0,0,0,0,0);
          if (isCheckinRequest) {
            pw.println();
          }
        }
 else {
          try {
            pw.flush();
            thread.dumpMemInfo(fd,mi,isCheckinRequest,dumpFullDetails,dumpDalvik,innerArgs);
          }
 catch (          RemoteException e) {
            if (!isCheckinRequest) {
              pw.println("String_Node_Str");
              pw.flush();
            }
          }
        }
      }
      final long myTotalPss=mi.getTotalPss();
      final long myTotalUss=mi.getTotalUss();
synchronized (this) {
        if (r.thread != null && oomAdj == r.getSetAdjWithServices()) {
          r.baseProcessTracker.addPss(myTotalPss,myTotalUss,true,r.pkgList);
        }
      }
      if (!isCheckinRequest && mi != null) {
        totalPss+=myTotalPss;
        MemItem pssItem=new MemItem(r.processName + "String_Node_Str" + pid+ (hasActivities ? "String_Node_Str" : "String_Node_Str"),r.processName,myTotalPss,pid,hasActivities);
        procMems.add(pssItem);
        procMemsMap.put(pid,pssItem);
        nativePss+=mi.nativePss;
        dalvikPss+=mi.dalvikPss;
        otherPss+=mi.otherPss;
        for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
          long mem=mi.getOtherPss(j);
          miscPss[j]+=mem;
          otherPss-=mem;
        }
        if (oomAdj >= ProcessList.CACHED_APP_MIN_ADJ) {
          cachedPss+=myTotalPss;
        }
        for (int oomIndex=0; oomIndex < oomPss.length; oomIndex++) {
          if (oomAdj <= DUMP_MEM_OOM_ADJ[oomIndex] || oomIndex == (oomPss.length - 1)) {
            oomPss[oomIndex]+=myTotalPss;
            if (oomProcs[oomIndex] == null) {
              oomProcs[oomIndex]=new ArrayList<MemItem>();
            }
            oomProcs[oomIndex].add(pssItem);
            break;
          }
        }
      }
    }
  }
  if (!isCheckinRequest && procs.size() > 1) {
    updateCpuStatsNow();
synchronized (mProcessCpuThread) {
      final int N=mProcessCpuTracker.countStats();
      for (int i=0; i < N; i++) {
        ProcessCpuTracker.Stats st=mProcessCpuTracker.getStats(i);
        if (st.vsize > 0 && procMemsMap.indexOfKey(st.pid) < 0) {
          if (mi == null) {
            mi=new Debug.MemoryInfo();
          }
          if (!brief && !oomOnly) {
            Debug.getMemoryInfo(st.pid,mi);
          }
 else {
            mi.nativePss=(int)Debug.getPss(st.pid,tmpLong);
            mi.nativePrivateDirty=(int)tmpLong[0];
          }
          final long myTotalPss=mi.getTotalPss();
          totalPss+=myTotalPss;
          MemItem pssItem=new MemItem(st.name + "String_Node_Str" + st.pid+ "String_Node_Str",st.name,myTotalPss,st.pid,false);
          procMems.add(pssItem);
          nativePss+=mi.nativePss;
          dalvikPss+=mi.dalvikPss;
          otherPss+=mi.otherPss;
          for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
            long mem=mi.getOtherPss(j);
            miscPss[j]+=mem;
            otherPss-=mem;
          }
          oomPss[0]+=myTotalPss;
          if (oomProcs[0] == null) {
            oomProcs[0]=new ArrayList<MemItem>();
          }
          oomProcs[0].add(pssItem);
        }
      }
    }
    ArrayList<MemItem> catMems=new ArrayList<MemItem>();
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",nativePss,-1));
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",dalvikPss,-2));
    catMems.add(new MemItem("String_Node_Str","String_Node_Str",otherPss,-3));
    for (int j=0; j < Debug.MemoryInfo.NUM_OTHER_STATS; j++) {
      String label=Debug.MemoryInfo.getOtherLabel(j);
      catMems.add(new MemItem(label,label,miscPss[j],j));
    }
    ArrayList<MemItem> oomMems=new ArrayList<MemItem>();
    for (int j=0; j < oomPss.length; j++) {
      if (oomPss[j] != 0) {
        String label=isCompact ? DUMP_MEM_OOM_COMPACT_LABEL[j] : DUMP_MEM_OOM_LABEL[j];
        MemItem item=new MemItem(label,label,oomPss[j],DUMP_MEM_OOM_ADJ[j]);
        item.subitems=oomProcs[j];
        oomMems.add(item);
      }
    }
    if (!brief && !oomOnly && !isCompact) {
      pw.println();
      pw.println("String_Node_Str");
      dumpMemItems(pw,"String_Node_Str","String_Node_Str",procMems,true,isCompact);
      pw.println();
    }
    if (!isCompact) {
      pw.println("String_Node_Str");
    }
    dumpMemItems(pw,"String_Node_Str","String_Node_Str",oomMems,false,isCompact);
    if (!brief && !oomOnly) {
      PrintWriter out=categoryPw != null ? categoryPw : pw;
      if (!isCompact) {
        out.println();
        out.println("String_Node_Str");
      }
      dumpMemItems(out,"String_Node_Str","String_Node_Str",catMems,true,isCompact);
    }
    if (!isCompact) {
      pw.println();
    }
    MemInfoReader memInfo=new MemInfoReader();
    memInfo.readMemInfo();
    if (!brief) {
      if (!isCompact) {
        pw.print("String_Node_Str");
        pw.print(memInfo.getTotalSizeKb());
        pw.println("String_Node_Str");
        pw.print("String_Node_Str");
        pw.print(cachedPss + memInfo.getCachedSizeKb() + memInfo.getFreeSizeKb());
        pw.print("String_Node_Str");
        pw.print(cachedPss);
        pw.print("String_Node_Str");
        pw.print(memInfo.getCachedSizeKb());
        pw.print("String_Node_Str");
        pw.print(memInfo.getFreeSizeKb());
        pw.println("String_Node_Str");
      }
 else {
        pw.print("String_Node_Str");
        pw.print(memInfo.getTotalSizeKb());
        pw.print("String_Node_Str");
        pw.print(cachedPss + memInfo.getCachedSizeKb() + memInfo.getFreeSizeKb());
        pw.print("String_Node_Str");
        pw.println(totalPss - cachedPss);
      }
    }
    if (!isCompact) {
      pw.print("String_Node_Str");
      pw.print(totalPss - cachedPss + memInfo.getBuffersSizeKb() + memInfo.getShmemSizeKb() + memInfo.getSlabSizeKb());
      pw.print("String_Node_Str");
      pw.print(totalPss - cachedPss);
      pw.print("String_Node_Str");
      pw.print(memInfo.getBuffersSizeKb());
      pw.print("String_Node_Str");
      pw.print(memInfo.getShmemSizeKb());
      pw.print("String_Node_Str");
      pw.print(memInfo.getSlabSizeKb());
      pw.println("String_Node_Str");
      pw.print("String_Node_Str");
      pw.print(memInfo.getTotalSizeKb() - totalPss - memInfo.getFreeSizeKb()- memInfo.getCachedSizeKb()- memInfo.getBuffersSizeKb()- memInfo.getShmemSizeKb()- memInfo.getSlabSizeKb());
      pw.println("String_Node_Str");
    }
    if (!brief) {
      if (memInfo.getZramTotalSizeKb() != 0) {
        if (!isCompact) {
          pw.print("String_Node_Str");
          pw.print(memInfo.getZramTotalSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb() - memInfo.getSwapFreeSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb());
          pw.println("String_Node_Str");
        }
 else {
          pw.print("String_Node_Str");
          pw.print(memInfo.getZramTotalSizeKb());
          pw.print("String_Node_Str");
          pw.print(memInfo.getSwapTotalSizeKb());
          pw.print("String_Node_Str");
          pw.println(memInfo.getSwapFreeSizeKb());
        }
      }
      final int[] SINGLE_LONG_FORMAT=new int[]{Process.PROC_SPACE_TERM | Process.PROC_OUT_LONG};
      long[] longOut=new long[1];
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long shared=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long sharing=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long unshared=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      longOut[0]=0;
      Process.readProcFile("String_Node_Str",SINGLE_LONG_FORMAT,null,longOut,null);
      long voltile=longOut[0] * ProcessList.PAGE_SIZE / 1024;
      if (!isCompact) {
        if (sharing != 0 || shared != 0 || unshared != 0 || voltile != 0) {
          pw.print("String_Node_Str");
          pw.print(sharing);
          pw.print("String_Node_Str");
          pw.print(shared);
          pw.println("String_Node_Str");
          pw.print("String_Node_Str");
          pw.print(unshared);
          pw.print("String_Node_Str");
          pw.print(voltile);
          pw.println("String_Node_Str");
        }
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetMemoryClass());
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetLargeMemoryClass());
        pw.print("String_Node_Str");
        pw.print(mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024);
        pw.print("String_Node_Str");
        pw.print("String_Node_Str");
        pw.print(mProcessList.getCachedRestoreThresholdKb());
        pw.print("String_Node_Str");
        if (ActivityManager.isLowRamDeviceStatic()) {
          pw.print("String_Node_Str");
        }
        if (ActivityManager.isHighEndGfx()) {
          pw.print("String_Node_Str");
        }
        pw.println();
      }
 else {
        pw.print("String_Node_Str");
        pw.print(sharing);
        pw.print("String_Node_Str");
        pw.print(shared);
        pw.print("String_Node_Str");
        pw.print(unshared);
        pw.print("String_Node_Str");
        pw.println(voltile);
        pw.print("String_Node_Str");
        pw.print(ActivityManager.staticGetMemoryClass());
        pw.print(',');
        pw.print(ActivityManager.staticGetLargeMemoryClass());
        pw.print(',');
        pw.print(mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024);
        if (ActivityManager.isLowRamDeviceStatic()) {
          pw.print("String_Node_Str");
        }
        if (ActivityManager.isHighEndGfx()) {
          pw.print("String_Node_Str");
        }
        pw.println();
      }
    }
  }
}