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 ()