Android memory allocation to your app

Source: Internet
Author: User

In Android, devices with different sizes of RAM will be allocated different initial running memory. Higher-resolution devices are also sure to require more memory than lower-resolution devices. How much is allocated, this can be viewed in your device/system/build.prop files , there are instructions. (Below is the information of my test equipment LG 720P resolution 4.7 inch phone)

<span style= "White-space:pre" ></span>dalvik.vm.heapstartsize = 8m        dalvik.vm.heapsize = 256m          dalvik.vm.heapgrowthlimit= 70m  
Heapgrowthlimit is a memory limit for a common application ,OKwith Activitymanager.getlargememoryclass ()method is obtained.

Heapstartsize is the initial memory, the application with the use, the memory is constantly automatically increased, will slowly reach the maximum memory limit.

The Androidmanifest.xml application tag has a android:largeheap= "true" property, and when set to True, you can request more memory from the device, The default is False. Even if this is set to true, it will not be allocated in unlimited amounts, and will still be reported as Oom error when a certain threshold is reached. So Google does not recommend this to do, as a development we should first consider how to reduce memory or reduce the use of incremental memory, rather than blindly to increase the memory space.

In the development, in order to avoid oom, we should try to optimize the algorithm logic, using the official recommended methods, such as 2.3 commonly used weakreference and softreference, to the present LRUCache class and so on,

good applications should have a reasonable and clear memory allocation, rather than random to create new objects, constantly open the page does not close the old page, or a lot of resources to do the cache and so on. Timely release of memory, and before caching some of the image resources through a similar getlargememoryclass () method to know in advance the application of the maximum memory, so as to reasonably preset the size of the cache, to effectively avoid the oom problem.



Android memory allocation to your app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.