开发者

trouble using Debug.MemoryInfo

开发者 https://www.devze.com 2023-02-10 01:28 出处:网络
I am trying to get memory usage values using this class, but all the class members are zero.I am calling it like this:

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 );
0

精彩评论

暂无评论...
验证码 换一张
取 消