title: How to interpret values of /proc/meminfo on Android?
body: <p>I am writing an Android app that needs to measure current free/used RAM. </p>
  
  <p>Searching this site showed multiple threads with similar topics that generally suggest two approaches:</p>
  
  <hr>
  
  <p>Approach 1:</p>
  
  <pre><code>MemoryInfo mi = new MemoryInfo();
  ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  activityManager.getMemoryInfo(mi);
  long availableMegs = mi.availMem / 1048576L;
  totalMegs = mi.totalMem / 1048576L;  //available since API 16 only
  </code></pre>
  
  <hr>
  
  <p>Approach 2: parsing /proc/meminfo.</p>
  
  <p>I have tried both approaches and they seem to work ok. I get the same values from both methods. 
  My issue is that when I go to <code>Settings -&gt; Apps -&gt; Running</code> at the bottom of the screen is information about free/used RAM and this differs from what I get with above mentioned methods.
  My suspicion is that Google does report cached apps as free memory, because when I kill some cached processes, Google's reported RAM usage barely changes, but my apps does in an amount that is close to size of the running process I just killed. </p>
  
  <p>Example:</p>
  
  <p>Approach 1 output:</p>
  
  <pre><code>meminfo: avail: 660, total: 821, used: 161
  </code></pre>
  
  <p>Approach 2 output:</p>
  
  <pre><code>root@android:/proc # cat meminfo
  MemTotal:         840868 kB
  MemFree:          548080 kB
  Buffers:               0 kB
  Cached:           128300 kB
  SwapCached:            0 kB
  Active:           192052 kB
  Inactive:          79816 kB
  Active(anon):     157792 kB
  Inactive(anon):        0 kB
  Active(file):      34260 kB
  Inactive(file):    79816 kB
  Unevictable:           0 kB
  Mlocked:               0 kB
  SwapTotal:             0 kB
  SwapFree:              0 kB
  Dirty:                 0 kB
  Writeback:             0 kB
  AnonPages:        143580 kB
  Mapped:            67584 kB
  Slab:               6736 kB
  SReclaimable:       2104 kB
  SUnreclaim:         4632 kB
  PageTables:         4008 kB
  NFS_Unstable:          0 kB
  Bounce:                0 kB
  WritebackTmp:          0 kB
  CommitLimit:      420432 kB
  Committed_AS:    1606616 kB
  VmallocTotal:     122880 kB
  VmallocUsed:       20588 kB
  VmallocChunk:      77828 kB
  
  MemFree + Cached = 660MB
  
  
  Android reported RAM usage: 679MB Free, 142MB used.
  </code></pre>
  
  <p>How can I get the same numbers as Android reports? </p>
  
  <p>I assume I have to get it from <code>/proc/meminfo</code> as the official API seems not to exist. </p>