Android calculates the percentage of memory used currently. android percentage

Source: Internet
Author: User

Android calculates the percentage of memory used currently. android percentage

Some Mobile Phone Manager software can display the percentage of memory used by the current system. This number is calculated by the ratio of the total memory size, the available memory size, and the total memory size, the following code calculates the memory usage.

/*** Calculate the percentage of memory in use **/public static String getUsedPercentValue (Context context) {String dir = "/proc/meminfo "; try {FileReader fr = new FileReader (dir); BufferedReader br = new BufferedReader (fr, 2048); String memoryLine = br. readLine (); String subMemoryLine = memoryLine. substring (memoryLine. indexOf ("MemTotal:"); br. close (); long totalMemorySize = Integer. parseInt (subMemoryLine. replaceAll ("\ D +", ""); l Ong availableSize = getAvailableMemory (context)/1024; int percent = (int) (totalMemorySize-availableSize)/(float) totalMemorySize * 100); return percent + "% ";} catch (IOException e) {e. printStackTrace ();} return "no result";}/*** get the current available memory. The returned data is in bytes. * @ Return the current available memory. */Private static long getAvailableMemory (Context context) {ActivityManager. MemoryInfo mi = new ActivityManager. MemoryInfo (); getActivityManager (context). getMemoryInfo (mi); return mi. availMem ;}



Android smart phone memory usage is normal

Generally, the mobile phone is between 50 and 90%. It depends on how much memory and software is running on your mobile phone. 75 is normal, not much, but most mobile phone memory is 512 MB.
 
My mobile phone is Android, and the running memory is 236 mb. The percentage of memory running when the software is not running on the phone is more than 60%.

Some software is automatically started upon startup, for example, the input method is used for storage. After the boot, you use 360 to clean up the system and check whether there are many built-in things and people on Android phones that haven't been flushed. and so on.
 

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.