AndroidManifest.xml文件<applicatiion>中能够设置 android:largeHeap="true"
我使用的测试设备为Nexus5 系统为5.0
安卓设备对应用内存的限制,通常在/system/build.prop文件中能够查看到
dalvik.vm.heapsize=512m(最大内存限制)
dalvik.vm.heapgrowthlimit=192m(普通内存限制)
当设置为android:largeHeap="true" 时
内存溢出
03-03 15:21:51.480: I/art(11679): Clamp target GC heap from 513MB to 512MB
当设置为android:largeHeap="false" 时
内存溢出
03-03 15:29:00.711: I/art(14283): Clamp target GC heap from 205MB to 192MB
测试方法为不断的加载图片到内存,好比
Bitmap bitmap[] = new Bitmap[300];
for (int i=0; i<bitmap.length; i++) {
bitmap[i] = BitmapFactory.decodeResource(getResources(), R.drawable.eee);
}
得到最大内存限制:
android3.0及以上可调用此方法
((ActivityManager)getSystemService(Context.ACTIVITY_SERVICE)).getLargeMemoryClass();android