Android:如何获取内部总/可用内存?

发布于 2024-10-05 13:21:55 字数 1141 浏览 7 评论 0原文

RAM 内存和内部闪存之间有区别吗? 我可以通过以下方式获取 RAM 内存:

cat /proc/meminfo

但是,我不确定如何获取闪存信息。

我想我知道如何获得可用内存:

ActivityManager activityManager = (ActivityManager).getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
memoryInfo.availMem;

这是否提供可用的内部闪存?

内存总量怎么样?

以下 unix 命令可以获取此信息吗?

df

结果:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    97744         0     97744   0% /dev
tmpfs                     4096         0      4096   0% /sqlite_stmt_journals
/dev/block/mtdblock3    174080    154372     19708  89% /system
/dev/block/mtdblock5    169728     57144    112584  34% /data
/dev/block/mtdblock4    133120     89632     43488  67% /cache
/dev/block/mtdblock4    133120     89632     43488  67% /data/dalvik-cache
/dev/block//vold/179:1
                       7970928   2358576   5612352  30% /sdcard

如果是这样,我是否必须添加所有 tmpfs 和 tmpfs? /dev/block/mtdblock# 获取总内部内存?

There's a difference between RAM memory and internal flash memory right?
I can get RAM memory by:

cat /proc/meminfo

However, I am not sure how to get Flash memory information.

I think I know how to get available memory:

ActivityManager activityManager = (ActivityManager).getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
memoryInfo.availMem;

Does this give available internal Flash memory?

How about total internal memory?

Does following unix command get me this info?

df

result:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    97744         0     97744   0% /dev
tmpfs                     4096         0      4096   0% /sqlite_stmt_journals
/dev/block/mtdblock3    174080    154372     19708  89% /system
/dev/block/mtdblock5    169728     57144    112584  34% /data
/dev/block/mtdblock4    133120     89632     43488  67% /cache
/dev/block/mtdblock4    133120     89632     43488  67% /data/dalvik-cache
/dev/block//vold/179:1
                       7970928   2358576   5612352  30% /sdcard

if so, do I have to add all tmpfs & /dev/block/mtdblock# to get total internal memory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人海汹涌 2024-10-12 13:21:55

df 告诉您有关文件系统上的空间的信息...即,将闪存视为“磁盘”

至于将其添加...取决于您想知道的内容。添加不同的分区有点可疑,因为它们不能完全互换。还有其他 mtd 分区没有文件系统或在正常操作期间不会安装 - 它们包含引导加载程序、无线电固件、linux 内核和压缩根文件系统等内容,以及内核和压缩文件系统。恢复系统。

您可能会更好地查看内核启动消息并查看它以 ram 和 mtd 设备的方式找到了什么。

但是,还有内核无法访问的内部存储器,而是由无线电协处理器使用。因此,如果您确实想要安装总量,最好阅读制造商的规格。

否则,您应该坚持使用可能可供应用程序使用的内存......

df tells you about the space on file systems... ie, think of flash as 'disk'

As for adding it up... depends on what you want to know. Adding up distinct partitions is a bit dubious since they aren't exactly interchangeable. And there are other mtd partitions that don't have file systems or don't get mounted during normal operation - they contain things like bootloaders, radio firmware, the linux kernel and compressed root filesystem, and also the kernel and compressed file system for the recovery system.

You might do better to look through the kernel boot messages and see what it finds in the way of ram and mtd devices.

But then, there's also internal memory that is not accessible to the kernel and is instead used by the radio coprocessor. So if you actually want the total installed, it's probably best to read the manufacturers specifications.

Otherwise, you should stick to the memory that might conceivably be available to applications...

世态炎凉 2024-10-12 13:21:55
cat /proc/meminfo

会给你一些关于运行内存的信息,但是Dalvik倾向于占用尽可能多的内存......

要挖掘更多Android内存,你应该使用DDMS。

cat /proc/meminfo

will give you some information about the running memory, but Dalvik tends to take as much memory as possible...

To dig more into the Android memory, you should use DDMS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文