问题描述
我正试图在我的java应用程序中找到内存泄漏的原因。我需要为长 GC循环中的进程获取堆转储。 Jmap在这种情况下不起作用,因为app被挂起并且因为堆非常大。
I'm trying to find the cause of memory leaks in my java application. I need to get a heap dump for a process that is in a long GC-cycle. Jmap isn't working in this case both because app is hanged and because heap is very large.
不幸的是,jmap在我采取的核心转储上抛出UnknownOopException。我想在GC期间采取核心转储是不正确的。有没有办法在核心转储正确的时候暂停java进程?
Unfortunately, jmap throws UnknownOopException on the core dump I took. I suppose that it isn't correct to take core dump during GC. Is there any way to suspend java process at the point where taking core dump will be correct?
或者我完全错了并且由于其他一些问题而被破坏了核心转储?
Or am I totally wrong and got broken core dump because of some other problem?
推荐答案
执行GC时无法进行堆转储。您需要在GC之前或之后进行堆转储。如果你想知道为什么花了这么长时间,确定哪个pahse花了这么长时间是有用的。要查看此内容,请添加 -verbosegc
这将指示是否需要很长时间才能到达安全点,复制对象,扫描tenrured空间,检查引用或其他内容。
You cannot take a heap dump while a GC is being performed. You need to take a heap dump before or after the GC. If you want to know why it is taking so long it is usueful to determine which pahse is taking so long. To see this to add -verbosegc
This will indicate if it is taking a long time to reach a safe point, copy objects, scan the tenrured space, check references or something else.
可能需要花时间,因为你有很多物品需要清理。作为猜测,每2 GB堆对象可能需要1秒钟的最坏情况。
It could be taking along time because you have lots of objects to clean up. As a guessimate it can take about a worst case 1 second per 2 GB of heap objects.
这篇关于如果应用程序在GC中,如何可靠地获取JVM核心转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!