Wednesday, March 26, 2014

Get the "Settings" interface "Available RAM - How to get available RAM in settings


Recently encountered a problem, hoping to get everyone's help, novice posting, publishing bad, but really sincere.

Problem: Get the "Settings" interface "Available RAM

Methods: In order to get the available RAM, I watched " red wolf blog " There's an article: < a href = "http://www.redwolf-blog.com/?p=1551 # respond" target = "_blank"> Android in memory usage statistics : http://www.redwolf-blog . com / p = 1551 # respond; which referred to obtaining "Available RAM" method is:?
 String sizeStr = Formatter.formatShortFileSize (getContext (), mLastAvailMemory + mLastBackgroundProcessMemory); long availMem = readAvailMem () - SECONDARY_SERVER_MEM; 

In readAvailMem, depending on the value of / proc / meminfo file MemFree and Cached Avail two calculated values, but also subtract SECONDARY_SERVER_MEM (property ro.SECONDARY_SERVER_MEM usually located in the build/target/board/generic_x86/init.rc as 4096, so that the block of memory is 4096 * PAGE_SIZE = 16MB)
Therefore, the "free space" means unused memory (free + cached) + space occupied by a background process - reserved space (SECONDARY_SERVER_MEM, typically 16MB). Because the Low Memory Killer's role in the less memory space daemon process can be released, it contains a space daemon.

Conclusion: So I have concluded that:
Available RAM = idle memory (free + cached) + space occupied by a background process - reserved space;

Problem Details: here there have been my problem, I get space reserved (SECONDARY_SERVER_MEM) when using the source inside that function :
 / / Magic! Implementation detail! Don't count on this! 
SECONDARY_SERVER_MEM =
Integer.valueOf (SystemProperties.get ("ro.SECONDARY_SERVER_MEM")) * PAGE_SIZE;

But the results SystemProperties.get ("ro.SECONDARY_SERVER_MEM") returns: Empty!

Finally: So I feel that I have not read the contents of the file where SECONDARY_SERVER_MEM, so I want to ask you brother, how can I read ro.SECONDARY_SERVER_MEM, or how I can get SECONDARY_SERVER_MEM it, thank the hope Members brothers spoke enthusiastically taking part in this thank you.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->

No comments:

Post a Comment