Android memory-obtain the memory limit of a single application

Source: Internet
Author: User

Android memory-obtain the memory limit of a single application
I. Why is the problem OutOfMemeryError? Androd has memory restrictions for each application

2. Why is the maximum memory usage restricted for each application? 1. You can run multiple tasks at the same time. It is impossible for each task to occupy as much memory as possible.
2. If the heap is large, it takes too much time for garbage collection.
Cache cleanup requires that all applications be paused and then cleaned and sorted. About 3, 4, 5 milliseconds
Google I/O 2011: Memory management for Android Apps

3. Obtain the memory size of the Android mobile phone application. The performance of the mobile phone varies depending on the memory size of the mobile phone. Therefore, the memory size of the mobile phone may vary with the app.
Method 1:

Adb shell getprop | grep dalvik. vm. heapgrowthlimit [dalvik. vm. heapgrowthlimit]: [64 m]

Method 2:
ActivityManager activityManager = (ActivityManager) context. getSystemService (Context. ACTIVITY_SERVICE); activityManager. getMemoryClass (); activityManager. getLargeMemoryClass ();

Method 3:
Adb shell cat/system/build. propdalvik. vm. heapstartsize = 8 m dalvik. vm. heapgrowthlimit = 64 m dalvik. vm. heapsize = 256 m

Method 4:
Runtime. getRuntime (). maxMemory ()




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.