Android 如何从 ADB 获取可用/空闲内存?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22843468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the available/free memory from ADB?
提问by HymanWM
I tried adb shell top
, but it gives too much details info.
我试过adb shell top
,但它提供了太多详细信息。
What I need is just the total available memory. How to get it via ADB?
我需要的只是可用内存总量。如何通过亚行获取?
回答by gavenkoa
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.
大多数手机缺乏free
实用性,尤其是 buzybox。另一方面/proc/meminfo
是Linux不可分割的一部分。
回答by HymanWM
The most "clean" way I found so far is adb shell vmstat
到目前为止我发现的最“干净”的方式是 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.
其中,99120
是以KB为单位的可用内存。
回答by pevik
How about using busybox
?
怎么用busybox
?
adb shell busybox free -m
total used free shared buffers
Mem: 741 503 237 0 5
-/+ buffers: 498 242
Swap: 0 0 0