简体   繁体   English

android中的dalvik堆和本机堆有什么区别?哪一个是固定的。?

[英]what is the difference between dalvik heap and native heap in android? which one is fixed.?

I guess Dalvik heap is fixed for android app. 我猜Dalvik堆是固定的Android应用程序。 like 64MB, 96MB etc. 像64MB,96MB等

is it right ?. 这样对吗 ?。

If so, is native heap is also fixed to some size ? 如果是这样,本机堆也固定为某种大小? or will grow depending on the app usage? 或将根据应用程序的使用增长?

can anyone please help me out? 有人可以帮帮我吗? thanks. 谢谢。

I guess Dalvik heap is fixed for android app. 我猜Dalvik堆是固定的Android应用程序。 like 64MB, 96MB etc. 像64MB,96MB等
Is it right?. 这样对吗?。

Android proposes a particular value for apps as the limit based on the Android Version ( getMemoryClass() API of the class ActivityManager will give you the value for the device your code is running on), but vendors tweak it to increase it by a margin that suits their requirements (for eg in the case of hardware supporting higher screen resolutions as larger resolutions will use larger bitmaps). Android为应用程序提供了一个特定值,因为基于Android版本的限制(ActivityManager类的getMemoryClass() API将为您的代码运行的设备提供价值),但是供应商调整它以增加它的余量适合他们的要求(例如,在硬件支持更高屏幕分辨率的情况下,因为更大的分辨率将使用更大的位图)。

If so, is native heap is also fixed to some size ? 如果是这样,本机堆也固定为某种大小? or will grow depending on the app usage? 或将根据应用程序的使用增长?

Yes, there is no hard limit as it grows depending on the usage. 是的,根据使用情况,它没有硬限制。 You can use as much memory as the device has available (ie Total memory - memory used by other programs). 您可以使用设备可用的内存(即总内存 - 其他程序使用的内存)。 When Android thinks that it's getting low on memory, then based on many factors (whether or not it's in the foreground, or providing services to some foreground app), it'll start killing processes. 当Android认为内存不足时,那么基于许多因素(无论它是否在前台,或者为某些前台应用程序提供服务),它将开始杀死进程。 You can get more info about the device's memory using android.app.ActivityManager.MemoryInfo . 您可以使用android.app.ActivityManager.MemoryInfo获取有关设备内存的更多信息。 Also since Android 3.0, apps can request a larger heap (Although, one should avoid it until and unless its completely unavoidable). 此外,自Android 3.0以来,应用程序可以请求更大的堆(虽然,除非完全不可避免,否则应该避免使用它)。 You can increase the heap size by using android:largeheap="true" in your manifest file 您可以在清单文件中使用android:largeheap="true"来增加堆大小

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

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