1

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

but them dbm.dalvikPss (and the other class members) are zero. Any ideas? Thanks in advance.

2 Answers 2

6

You have to call Debug.getMemoryInfo() to populate it.

MemoryInfo dbm = new MemoryInfo();
Debug.getMemoryInfo(dbm);
Sign up to request clarification or add additional context in comments.

1 Comment

bingo! I thought that the constructor populated it. Thanks!
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.