答案 0 :(得分:1)
您可以尝试使用dumpsys meminfo
来获取内存。
Process proc = Runtime.getRuntime().exec("");
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
DataOutputStream out = new DataOutputStream(proc.getOutputStream());
// periodically execute dumpsys meminfo
out.writeBytes("dumpsys meminfo\n");
out.flush();
// read mem log and do some parsing job
while (reader.ready()) {
line = reader.readLine();
// you can parse the log
}
答案 1 :(得分:0)
在这里,Debug.MemoryInfo可能会拯救你,查看Android开发人员文档here