是否可以创建堆转储以分析内存泄漏而无需垃圾回收? [英] Can heap dump be created for analyzing memory leak without garbage collection?

查看:153
本文介绍了是否可以创建堆转储以分析内存泄漏而无需垃圾回收?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在生产中运行Java应用程序的VM上存在一些内存泄漏问题,Old Gen堆使用量每天都在快速增长,所以我想创建堆转储来分析它。

We have some memory leak issues on VMs in production which are running Java applications, the Old Gen heap usage grows fast every day, so I want to create heap dump to analyze it.

但是,我注意到VisualVM将在堆转储之前执行完整的GC,这将清除旧的Gen,在这种情况下,堆转储将是无用的。

However, I noticed that VisualVM will perform full GC before heap dump which will clean the Old Gen, in that case, the heap dump would be useless.

我也尝试使用以下命令:

I also tried to use the following command:

jmap -dump:live,format = b,file = heap.bin

jmap -dump:live,format=b,file=heap.bin

它还会触发一个完整的GC。

It will also trigger a full GC.

请问是否有办法可以在没有完整GC(或没有GC)的情况下创建堆转储?或者有更好的方法来分析内存泄漏吗?

May I ask if there is a way that heap dump can be created without full GC (or without GC)? Or is there any better way to analyze the memory leak?

JDK版本:1.7.0_45

JDK version: 1.7.0_45

谢谢。

推荐答案

要创建堆转储,将有一个Full GC。从堆中创建类直方图时也是如此。

To create a heap dump, there will be a Full GC. The same applies when creating Class histogram out of heap.

如果要分析Full GCs之间的内存泄漏,那么可能内存分析使用Java分析器(Mission Control,jProfiler等)是您唯一的选择。

If you want to analyze memory leak between Full GCs, then probably memory profiling using a Java profiler (Mission Control, jProfiler, etc) is your only option.

有关 Java任务控制堆配置文件

这篇关于是否可以创建堆转储以分析内存泄漏而无需垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆