The JAVA virtual machine has a maximum memory limit for a single process. If you exceed this limit, an OOM will be thrown. This property value is defined in the /system/build.prop file. This value can vary from device to device, and the ROM of each manufacturer will change this value according to the device configuration. The first Android phone (G1) was 16 MB.

Application of maximum memory. Default is dalvik vm. Heapgrowthlimit (only for dalvik heap, not including native heap)

If you want to be allowed to get more memory, you can use Android :largeHeap=”true”, which changes to dalvik.vm.heapsize after using largeHeap.

The adb shell getprop dalvik. Vm. Heapsize 512 m -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - build. Prop part -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- dalvik.vm.heapstartsize=16m dalvik.vm.heapgrowthlimit=384m dalvik.vm.heapsize=512m ro.com.google.gmsversion=10_202005 net.bt.name=AndroidCopy the code

You can also view the maximum application memory using the following code:

ActivityManager am = (ActivityManager) getApplication().getSystemService(Context.ACTIVITY_SERVICE); int limitMemorySize = am.getMemoryClass(); int largeMemorySize = am.getLargeMemoryClass(); long maxMemory = Runtime.getRuntime().maxMemory(); // Depending on whether largeHeap is equal to limitMemory or largeMemoryCopy the code

Although 64-bit addressing space is much larger than 32-bit, changing an application from 32-bit to 64-bit on Android does not result in a larger memory threshold; it is always heapgrowthlimit and HeapSize.