Heorhiy
Heorhiy

Reputation: 190

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];

Upvotes: 3

Views: 9863

Answers (2)

s.d
s.d

Reputation: 29436

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.

Upvotes: 1

DigCamara
DigCamara

Reputation: 5568

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.

Upvotes: 5

Related Questions