美文网首页
Android 内存分析

Android 内存分析

作者: 主音King | 来源:发表于2018-12-04 09:53 被阅读4次
        Runtime runtime = Runtime.getRuntime();
        String maxMemory = Formatter.formatFileSize(this, runtime.maxMemory());
        String totalMemory = Formatter.formatFileSize(this, runtime.totalMemory());
        String freeMemory = Formatter.formatFileSize(this, runtime.freeMemory());
        int availableProcessors = runtime.availableProcessors();

执行

dumpsys meminfo 包名

maxMemory是java虚拟机从操作系统挖的最大内存(Meizu PRO 5 Anroid7.0 API24是192MB)
Dalvik Heap中的Heap Size就是totalMemory的大小。java虚拟机从操作系统挖的内存大小,是慢慢增大的。
freeMemory是java虚拟机的空闲内存量
availableProcessors是java虚拟机(处理器)的最大可用数量

相关文章

网友评论

      本文标题:Android 内存分析

      本文链接:https://www.haomeiwen.com/subject/fmopcqtx.html