trouble using Debug.MemoryInfo
I am trying to get memory usage values using this class, but all the class members are zero. I am calling it like this:
android.os.Debug.MemoryInfo dbm = new android.os.Debug.MemoryInfo(开发者_如何学Go);
but them dbm.dalvikPss (and the other class members) are zero. Any ideas? Thanks in advance.
You have to call Debug.getMemoryInfo() to populate it.
MemoryInfo dbm = new MemoryInfo();
Debug.getMemoryInfo(dbm);
You can also do it based on the getProcessMemoryInfo(pids[])
int myPid = android.os.Process.myPid();
int[] pids = {myPid};
Debug.MemoryInfo[] memoryInfoPids = am.getProcessMemoryInfo (pids );
精彩评论