Proc/meminfo in Android (original)

Source: Internet
Author: User

Today, when it comes to getting the total size of the available memory space on the phone, it is not advisable to find that the minimum supported version of the method is 16 by the following method.

1  Public Static Longgettotalspace (Context ctx) {2      //1. Create a Activitymanager object3Activitymanager am =(Activitymanager)4 Ctx.getsystemservice (context.activity_service);5      //2 Getting an object that encapsulates memory information6Memoryinfo Memoryinfo =NewMemoryinfo ();//assigning values to Objects7 Am.getmemoryinfo (memoryinfo);8     returnMemoryinfo.totalmem;9}

After reading the data, the first line is the total size of the available memory space that I want to read through the Proc/meminfo, and the total size of the desired memory space in the form of a stream.

1 Try {2FileReader FileReader =NewFileReader ("Proc/meminfo");3BufferedReader br =NewBufferedReader (filereader);4 5String readLine = Br.readline ();//the size of the TOTALMEM is just after reading a line6 7             //match the ASCII value of the read string to the size of the required memory space8             Char[] Chararray =Readline.tochararray ();9 Ten             //string up the total size of free space by Stingbuffer OneStringBuffer SB =NewStringBuffer (); A              for(CharC:chararray) { -                 if(c >= ' 0 ' && C <= ' 9 ') { - Sb.append (c); the                 } -             } -             //convert SB into a string, noting that the unit in the database file is KB, and in order to be unified and convenient to use, convert to byte units -             returnLong.parselong (Sb.tostring ()) *1024; +  -}Catch(Exception e) { + e.printstacktrace (); A}

What does it mean, however, that information is generated about other data in Proc/meminfo?

Switch to the Linux environment via the ADB shell and switch to the directory, and get the following information via Cat Meminfo

Of course, you can find the corresponding file path in the DDMS, export, with Notepad open view, basically the same.

In response to these additional data, the respective explanations are as follows:

Memtotal: All available RAM size (that is, physical memory minus some reserved bits and kernel binary code size) Memfree:lowfree and Highfree, the system keeps unused memory buffers: used to buffer the file size cached: The amount of memory used by the cache memory (equal to DiskCache minus SwapCache). swapcached: The size of the swap space used by the cache memory, the memory that has been swapped out, But it is still stored in the swapfile. Used to quickly be replaced when needed without having to open the I/O port again. Active: The size of the buffer or buffer memory paging file in active use, unless it is necessary to be removed for his use. Inactive: The size of the paging file in infrequently used buffers or cache memory may be used in other ways. Hightotal:highfree: The zone is not mapped directly to the kernel space. The kernel must use this memory in a different manner. Lowtotal:lowfree: Low can achieve the same effect as high memory, and it can be used by the kernel to record some of its own data structures. Among many other things, it's where everything from the Slab is allocated. Bad things happen if you ' re out of Lowmem. Swaptotal: The total size of the swap space swapfree: the size of the swap space that is not being used dirty: The amount of memory waiting to be written back to the disk. Writeback: The amount of memory that is being written back to disk. Anonpages: Memory size of unmapped pages mapped: size of mappings such as devices and files. Slab: The size of the kernel data structure cache can reduce the consumption of application and release memory. Sreclaimable: recoverable Slab size Sunreclaim: Non-recoverable Slab size (Sunreclaim+sreclaimable=slab) Pagetables: Manages the size of the index table of the paged page of memory. Nfs_unstable: The size of the unstable page table Vmalloctotal: You can vmalloc the virtual memory size vmallocused: The amount of virtual memory that has been used. Vmallocchunk:largest contigious blocK of Vmalloc area which are free 

Personally feel that the above summary is still relatively good, here cited, as an extension ...

Proc/meminfo in Android (original)

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.