下载MAT工具,下载地址:https://www.eclipse.org/mat/d...,解压后,windows的话直接运行MemoryAnalyzer.exe便可php
写一段会oom的代码java
public class GCtest { private String[] val = new String[10000]; public static void main(String[] args) { Map<String, GCtest> map = new HashMap<>(); int i = 0; while (true) { map.put(String.valueOf(i), new GCtest()); i++; } } }
添加运行参数windows
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=your path 不加HeapDumpPath 默认当前目录
运行代码,生成.hprof文件,运行mat分析工具打开文件,能够看出hashmap里面的对象迟迟没有释放微信