tools/android/appstats.py
def QueryMemory(adb, pid):
    """Queries the device for memory information about the process with a pid of
    |pid|.  It will query Native, Dalvik, and Pss memory of the process.  It
    returns a list of values: [ Native, Pss, Dalvik ].  If the process is not
    found it will return [ 0, 0, 0 ]."""
    results = [0, 0, 0]

    mem_lines = adb.RunShellCommand(
        ['dumpsys', 'meminfo', pid], check_return=True)
    for line in mem_lines:
      match = re.split('\s+', line.strip())

      # Skip data after the 'App Summary' line.  This is to fix builds where
      # they have more entries that might match the other conditions.
      if len(match) >= 2 and match[0] == 'App' and match[1] == 'Summary':
        break

      result_idx = None
      query_idx = None
      if match[0] == 'Native' and match[1] == 'Heap':
        result_idx = 0
        query_idx = -2
      elif match[0] == 'Dalvik' and match[1] == 'Heap':
        result_idx = 2
        query_idx = -2
      elif match[0] == 'TOTAL':
        result_idx = 1
        query_idx = 1

      # If we already have a result, skip it and don't overwrite the data.
      if result_idx is not None and results[result_idx] != 0:
        continue

      if result_idx is not None and query_idx is not None:
        results[result_idx] = round(float(match[query_idx]) / 1000.0, 2)
    return results
Queries the device for memory information about the process with a pid of
    |pid|.  It will query Native, Dalvik, and Pss memory of the process.  It
    returns a list of values: [ Native, Pss, Dalvik ].  If the process is not
    found it will return [ 0, 0, 0 ].
Queries the device for memory information about the process with a pid of
|pid|.  It will query Native, Dalvik, and Pss memory of the process.  It
returns a list of values: [ Native, Pss, Dalvik ].  If the process is not
found it will return [ 0, 0, 0 ].
Queries the device for memory information about the process with a pid of |pid| . It will query Native Dalvik and Pss memory of the process . It returns a list of values : [ Native Pss Dalvik ] . If the process is not found it will return [ 0 0 0 ] .
def QueryMemory(adb, pid):
    results = [0, 0, 0]
    mem_lines = adb.RunShellCommand(
        ['dumpsys', 'meminfo', pid], check_return=True)
    for line in mem_lines:
      match = re.split('\s+', line.strip())
      if len(match) >= 2 and match[0] == 'App' and match[1] == 'Summary':
        break
      result_idx = None
      query_idx = None
      if match[0] == 'Native' and match[1] == 'Heap':
        result_idx = 0
        query_idx = -2
      elif match[0] == 'Dalvik' and match[1] == 'Heap':
        result_idx = 2
        query_idx = -2
      elif match[0] == 'TOTAL':
        result_idx = 1
        query_idx = 1
      if result_idx is not None and results[result_idx] != 0:
        continue
      if result_idx is not None and query_idx is not None:
        results[result_idx] = round(float(match[query_idx]) / 1000.0, 2)
    return results
def QueryMemory ( adb , pid ) : results = [ 0 , 0 , 0 ] mem_lines = adb . RunShellCommand ( [ 'dumpsys' , 'meminfo' , pid ] , check_return = True ) for line in mem_lines : match = re . split ( '\s+' , line . strip ( ) ) if len ( match ) >= 2 and match [ 0 ] == 'App' and match [ 1 ] == 'Summary' : break result_idx = None query_idx = None if match [ 0 ] == 'Native' and match [ 1 ] == 'Heap' : result_idx = 0 query_idx = - 2 elif match [ 0 ] == 'Dalvik' and match [ 1 ] == 'Heap' : result_idx = 2 query_idx = - 2 elif match [ 0 ] == 'TOTAL' : result_idx = 1 query_idx = 1 if result_idx is not None and results [ result_idx ] != 0 : continue if result_idx is not None and query_idx is not None : results [ result_idx ] = round ( float ( match [ query_idx ] ) / 1000.0 , 2 ) return results
Queries the device for memory information about the process with a pid of
|pid|.
Queries the device for memory information about the process with a pid of |pid| .
"""Queries the device for memory information about the process with a pid of
    |pid|.  It will query Native, Dalvik, and Pss memory of the process.  It
    returns a list of values: [ Native, Pss, Dalvik ].  If the process is not
    found it will return [ 0, 0, 0 ].""" # Skip data after the 'App Summary' line.  This is to fix builds where # they have more entries that might match the other conditions. # If we already have a result, skip it and don't overwrite the data.
adb
pid