开发者

Android: How do you get internal Total/Available memory?

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   开发者_StackOverflow2358576   5612352  30% /sdcard

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


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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜