简体   繁体   中英

Android VM heap size

I can't understand what is android app heap size. Is it overall maxumum memory I can allocate both from java and frome native code? If yes then why on my google nexus S. this code

Runtime rt = Runtime.getRuntime();
long maxMemory = rt.maxMemory();
Log.v("onCreate", "maxMemory:" + Long.toString(maxMemory));

dysplays 50331648 = 48MB but dumpsys meminfo displays Native 13 16 12 84028 83457 18

and I can easily allocate say 74MB

int size = 1024*1024*74;
char* s = new char[size];

Well, heap size is actually a programming concept, much more than it's an Android one. You can read about it here , but it's really (short story) how much memory the VM is using and it's allocated independently from your app.

The memory allocated to your app is allocated dynamically. So, if you ask your app to allocate more memory you will see it grow. But it can't grow indefinitely.

Heap size is that amount of RAM that can be allocated. Each app is on a tiny Dalvik Virtual Machine. Each VM will have some heap space allocated.

And, there is a pre-defined heap-size settings inside /system/build.prop file for each device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM