Mobile-side test ===android Memory Management: Understanding PSS for the app

Source: Internet
Author: User

Android Memory Management: Understanding the app's PSS

Original link: http://www.littleeye.co/blog/2013/06/11/android-memory-management-understanding-app-pss/

When little eye is run on an application, 3 important statistics about application memory are reported in the memory view. Dalvik memory usage, that is, the amount of memory consumed by the Java heap, native memory, which is how much RAM is used by the external process of the JVM.

Then there is the third statistic, called "PSS". What is PSS?

propotionate set Size (scale set sizes)

The scale set size is the statistics that the Android system calculates to determine if you want to kill your process. Just looking at how much memory your application consumes is not the right way, because your application may use some shared memory with other processes, blaming your application for being using any shared memory is "unfair". Android systems may kill applications that use too much memory (especially if the application is in the background), so the Android system needs to find a way to reliably calculate the amount of memory the application is responsible for.

What is shared memory?

Android is a Linux-based system, and Linux uses the share page to share the same memory across processes. A common use of shared memory is to share "code" memory pages (memory areas that load read-only executable code) between processes. Executable code for external libraries and JVMs is an example of a region of memory that can be safely shared across processes. It can also be a data page, which is copy-on-write, which can be temporarily shared between processes until a process modifies the shared memory.

technology Application "real" memory usage

Therefore, for the use of memory for "fair" technology applications, the PSS statistic is used by Android. Basically, it's the non-shared memory that your application consumes and the amount of shared memory that can be "attributed to your application" (memory shared with other processes)/(the number of processes that share shared memory).

Now that Android has a "fairer" way to calculate who consumes a lot of memory, Android will start killing processes in the order of PSS from large to small.

What does it mean to be a developer?

If your application gets a very high PSS score, your application may be killed by the Android system. Maybe this is something you can handle, but accidental killing in the background can have an impact on your application, especially if you rely on some background activity or service to work. Make sure that your application's PSS is not too high, especially when your application enters the background. After entering the background, releasing the memory and objects that are not attracted, and disconnecting any shared memory that you no longer need, is probably a good idea. This will reduce your chances of accidentally being killed by the Android system.

One thing to keep in mind is that PSS does not have a "hard limit"-there is no guarantee that your application will be killed if it exceeds a certain threshold, or that a certain threshold value can survive. When the application is not in the foreground, it must be ready to be killed at any time. If the PSS value is low, it helps reduce those opportunities.

Mobile-side test ===android Memory Management: Understanding PSS for the 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.