android – How to get the available/free memory from ADB?-ThrowExceptions

Exception or error:

I tried adb shell top, but it gives too much details info.

What I need is just the total available memory. How to get it via ADB?

How to solve:

Why not built-in::

$ adb shell "cat /proc/meminfo"

Most phones lack free utility and all the more buzybox. On other hand /proc/meminfo is integral part of Linux.


The most “clean” way I found so far is adb shell vmstat

It gives the info as below:

procs  memory                       system          cpu
 r  b    free mapped   anon   slab    in   cs  flt  us ni sy id wa ir
 1  0   99120  55400 618680  25600  2207 4089    0   6  0  9 84  0  0

in which, the 99120 is the free memory in KB.


How about using busybox?

adb shell busybox free -m
             total         used         free       shared      buffers
Mem:           741          503          237            0            5
-/+ buffers:                498          242
Swap:            0            0            0

Leave a Reply

Your email address will not be published. Required fields are marked *