进入jvisualvm的插件管理
"工具" - "插件"
在线安装
在"设置"中修改url地址为刚才我们在github上找到的对应我们JDK版本的地址
修改成功后,可用插件即可刷新出来
离线安装
安装下载好的插件
下载地址:找到对应jdk版本然后安装对应版本的gc
https://visualvm.github.io/pluginscenters.html
安装VisualGC插件
即可看到VisualGC
实践:
public class OOMTest {
byte[] b = new byte[1024 * 10];
public static void main(String[] args) throws InterruptedException {
ArrayList<OOMTest> all = new ArrayList<>();
while (true) {
all.add(new OOMTest());
Thread.sleep(10);
}
}
}
可以看到一直在发生gc