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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:29:28  来源:igfitidea点击:

How to get the available/free memory from ADB?

androidadb

提问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 freeutility and all the more buzybox. On other hand /proc/meminfois 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 99120is 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