Default maximum memory size of Android applications

Source: Internet
Author: User
Original article: http://www.ziyouku.com/archives/android-applications-to-modify-the-default-maximum-memory-value.html

The default maximum memory size of Android applications is 16 Mb. Some applications may experience memory overflow, for example:

Error/androidruntime (264): Java. Lang. outofmemoryerror: bitmap size exceeds VM budget

In addition to checking the correction code, you can also consider modifying the default maximum memory value of the android application.

There are two ways to modify the default maximum memory of an application:

1. modify the code. It is applicable to self-Compiling and burning machines:

When the application allocates memory, it calls Dalvik/Vm/alloc/heapsource. the dvmtrackexternalallocation () method in C, and then calls the externalallocpossible () method. This method requires the size of the current heap used (composed of currentheapsize and HS-> externalbytesallocated) in addition, the size of the memory to be allocated again cannot exceed the maximum memory value of the heap. If it exceeds the value, an error is returned.

The maximum memory of a heap is determined in two places:
1) In Dalvik/Vm/init. C

Gdvm. heapsizemax = 16*1024*1024; // spec says 75% physical mem
2) In frameworks/base/CORE/JNI/androidruntime. cpp

Property_get ("Dalvik. VM. heapsize", heapsizeoptsbuf + 4, "16 m ");

Therefore, the solution is to increase the default 16 m in the above two points, such as 32 m.

2. modify the configuration file. It is applicable to versions after the machine is installed.

Modify or add the configuration item Dalvik. VM. heapsize = 32 m in/system/build. Prop.

Related Article

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.