简体   繁体   English

Android VM堆大小

[英]Android VM heap size

I can't understand what is android app heap size. 我无法理解什么是android app堆大小。 Is it overall maxumum memory I can allocate both from java and frome native code? 它是整体最大内存,我可以从java和frome本机代码分配? If yes then why on my google nexus S. this code 如果是,那么为什么在我的谷歌nexus S.这个代码

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 dysplays 50331648 = 48MB但dumpsys meminfo显示Native 13 16 12 84028 83457 18

and I can easily allocate say 74MB 我可以轻松分配说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. 好吧,堆大小实际上是一个编程概念,远远超过它的Android。 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. 你可以在这里阅读它,但它确实(简短的故事)VM使用了多少内存,它是独立于你的应用程序分配的。

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. 堆大小是可以分配的RAM量。 Each app is on a tiny Dalvik Virtual Machine. 每个应用程序都在一个小型Dalvik虚拟机上。 Each VM will have some heap space allocated. 每个VM都将分配一些堆空间。

And, there is a pre-defined heap-size settings inside /system/build.prop file for each device. 并且,每个设备的/system/build.prop文件中都有一个预定义的堆大小设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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