http://blog.csdn.net/vshuang/article/details/39647167 Android Memory Management &memory Leak & OOM Analysis
maximum memory available for a single app
After the Android device is shipped out, the maximum memory allocation for a single application is determined by the Java Virtual machine, which will be oom beyond this value. This attribute value is defined in the/system/build.prop file.
Dalvik.vm.heapstartsize=8m
It represents the initial size of the heap allocation, which affects how much RAM is used by the entire system, and how smoothly the application will be used for the first time.
The smaller the value, the slower the system RAM consumption, but some of the larger applications are not available at first, and need to invoke the GC and heap adjustment policies, causing the application to react more slowly. The larger the value, the greater the system's RAM consumption, but the smoother the application.
DALVIK.VM.HEAPGROWTHLIMIT=64M//Single application maximum memory available
The primary counterpart is this value, which indicates that a single process memory is limited to 64m, which means that only 64m of memory is actually used while the program is running, and Oom is reported beyond. (Only for Dalvik heap, not including native heap)
The Dalvik.vm.heapsize=384m//heapsize parameter represents the maximum amount of memory available to a single process, but if there is a heapgrowthlimit parameter, the Heapgrowthlimit is the standard.
HeapSize represents an uncontrolled limit heap, which represents the maximum memory available to a single virtual machine or a single process. Android apps have a standalone virtual machine, which opens a separate virtual machine for each application (so the design will not crash the entire system in the event of a single program crash).
Note: When Heapgrowthlimit is set, a single process can have a maximum memory value of Heapgrowthlimit. In Android development, if you want to use a large heap, you need to specify ANDROID:LARGEHEAP to true in manifest so that the DVM heap can be up to heapsize.
Different devices, these values can vary. Generally, manufacturers for the configuration of equipment will be appropriate to modify the/system/build.prop file to increase this value. As device hardware performance continues to improve, from the earliest 16M restrictions (G1 phones) to later 24m,32m,64m, all follow the Android framework's minimum memory size limit for each app, refer to http://source.android.com/ Compatibility/downloads.html 3.7 knots.
View the maximum memory available to each process by code, which is the Heapgrowthlimit value:
Activitymanager Activitymanager = (activitymanager) context.getsystemservice (Context.activity_service);
int memclass = Activitymanager.getmemoryclass ();//64, in M
Or:
$ADB Shell Getprop Dalvik.vm.heapgrowthlimit
192m
$ADB Shell Getprop dalvik.vm.heapsize
512m
$ADB Shell Getprop dalvik.vm.heapstartsize
16m
Http://hukai.me/android-training-managing_your_app_memory/Android Training-Manage the memory of your app
Check how much memory you should use
As mentioned earlier, each Android device will have a different total ram size and free space, so different devices offer different size heap limits for apps. You can get the available heap size for your app by calling Getmemoryclass ()). If your app tries to request more memory, there will be OutOfMemory
an error.
In some special scenarios, you can declare a larger heap space by adding attributes under the Application tab of the manifest largeHeap=true
. If you do this, you can get to a larger heap size by Getlargememoryclass ()).
However, the ability to get a larger heap is designed for a small number of applications that consume a lot of RAM (such as an editing application for a large picture). don't be so easy because you need to use a lot of memory to request a large heap size. Use the large heap only when you know exactly where to use a lot of memory and why the memory must be preserved. Therefore, use as little as possible the large heap. Using additional memory affects the overall user experience of the system and makes the GC run longer each time. The performance of the system becomes compromised when the task is switched.
In addition, the large heap does not necessarily get a larger heap. On some severely restricted machines, the size of the large heap is the same as the usual heap size. So even if you apply for the large heap, you should check the actual heap size by executing getmemoryclass ().
Android to view the maximum available memory per app