gpt4 book ai didi

java - 如何读取 Eclipse 内存分析器的 "Merge Shortest Paths to GC Roots"屏幕?

转载 作者:行者123 更新时间:2023-11-28 22:53:42 27 4
gpt4 key购买 nike

我正在努力解决这个问题

java.lang.OutOfMemoryError: Metaspace

在 Tomcat 8.0.18 上运行 Web 应用程序(Apache Roller、Java EE weblogger 软件:https://roller.apache.org)重新部署时。

我知道问题的原因可以通过 Eclipse Memory Analyzer 找到,所以我在 OOME 时得到了一个堆转储,它是由运行

的 JVM 自动生成的
-XX:+HeapDumpOnOutOfMemoryError.

我可以看到有 4 个 WebappClassLoader 实例应该被垃圾收集。但我不确定为什么这些实例没有被垃圾收集。 enter image description here

所以这是我在 Merge Shortest Paths to GC Roots => exclude all phantom/weak/soft/etc 中的问题。每个 WebappClassLoader 实例的引用 屏幕:

  1. 这是否意味着 PostgreSQL JDBC 驱动程序(部署在服务器端)有对 RollerContext 的引用? enter image description here

  2. 这看起来像 SoftEntryReference 的实例引用了 WebappClassLoader,但我猜它不是强引用,所以它不会阻止 WebappClassLoader 进行垃圾回收。我错了吗? enter image description here

  3. 我不知道这是什么意思……这是什么意思? WebappClassLoader 本身是否可以防止被垃圾收集? enter image description here

  4. 就像我在 2 中写的那样,我猜它应该被垃圾回收,因为它被 SoftReference 引用。我错了吗? enter image description here

最佳答案

Does this mean PostgreSQL JDBC Driver (deployed on the server side) has a reference to RollerContext?

是的,看起来是这样。特别是通过静态变量中保存的异常对象的回溯。

Merge Shortest Paths to GC Roots => exclude all phantom/weak/soft/etc. references

[...]

This looks like a instance of SoftEntryReference has a reference to WebappClassLoader, but I guess it is not a strong reference

[...]

Like I wrote in 2, I guess it should be garbage collected because it's referenced by a SoftReference. Am I wrong?

你错了。

就垃圾收集器而言,您没有查看软引用。软引用对象中只有一个字段不是强字段,即 referent。字段。

深入了解 JDK 的 java.lang.ref.Reference<T>类你会看到还有其他领域。你还会注意到 SoftReference是可子类化的,因此可以有额外的字段。所有非引用字段都是强引用。

MAT 表示您正在查看的内容由 discovered 链持有字段,这意味着引用对象肯定还活着,即使它们的引用对象可能已被回收。

I have no idea what this means... What does this mean? Does WebappClassLoader itself prevents to be garbage collected?

这在 eclipse docs 中有解释:它是 GC 根,因为该对象持有锁,并且因为它当前由 native 代码处理,例如JNI.

这是 "eclipse mat busy monitor" 的第一个谷歌结果.请进行研究。

关于java - 如何读取 Eclipse 内存分析器的 "Merge Shortest Paths to GC Roots"屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33073964/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com