每个android进程有多少内存?

前端之家收集整理的这篇文章主要介绍了每个android进程有多少内存?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们可以依靠我们的 Android应用程序获取一定量的内存,还是因手机型号或操作系统版本而有所不同?

例如,我有一个内存缓存,我将其限制设置为5 MB.如果在一个设备上,我的应用程序只能获得8 MB的内存来播放,另外一个是24 MB,我想调整内存缓存的上限以利用或多或少的内存.

有没有办法解决这个问题,数额甚至有所不同?

解决方法

是的,最大堆大小因设备而异.您可以通过调用 getMemoryClass()来检查设备的每个应用程序的近似值.

Returns the approximate per-application memory class of the current device. This gives you an idea of how hard a memory limit you should impose on your application to let the overall system work best. The returned value is in megabytes; the baseline Android memory class is 16 (which happens to be the Java heap limit of those devices); some device with more memory may return 24 or even higher numbers.

更改应用程序堆大小的唯一内置方法是在AndroidManifest.xml中设置android:largeHeap =“true”.这通常会将堆大小从48增加到128.请记住,这种方法只适用于3.x平板电脑.否则,您将需要一个根深蒂固的设备,这显然不是您希望作为开发人员的依据.

原文链接:https://www.f2er.com/android/312265.html

猜你在找的Android相关文章