[英]Java Memory issue : Java.lang.ref.finalizer object
In most of the research about the memory leak caused by finalizer object, either in our code or in a dependent library, one should be overriding the finalize method.在大多数关于由终结器 object 引起的 memory 泄漏的研究中,无论是在我们的代码中还是在依赖库中,都应该重写 finalize 方法。 But in my whole project its nowhere used.
但在我的整个项目中,它无处使用。 (I am using Java8)
(我使用的是Java8)
I am facing a memory issue, where for my service, as soon as I restart the service, the available memory starts reducing and within 7 days it is down by 95% with frequent warnings coming later on.我面临一个 memory 问题,对于我的服务,一旦我重新启动服务,可用的 memory 开始减少,并在 7 天内下降了 95%,随后会频繁出现警告。
Above graph shows the available memory in Y axis, which one can see reduces.
上图在 Y 轴上显示了可用的 memory,可以看到减少了。 All peaks in above graph is for restart of service.
上图中的所有峰值均用于重新启动服务。
When I went through the heap dump in eclipse Mat, I see the following:当我浏览 eclipse Mat 中的堆转储时,我看到以下内容:
As it can be seen, almost all the space is taken by 1 object only ie java.lang.ref.Finalizer
but when I did a field Java search in my project, I don't see any code using the finalize() method.可以看出,几乎所有空间都被 1 object 占用,即
java.lang.ref.Finalizer
但是当我在我的项目中搜索字段 Java 时,我没有看到任何使用 finalize() 方法的代码。
And I have hit a dead end trying to find the memory leak.我在寻找 memory 泄漏时遇到了死胡同。 Is there any other reason which might be causing the issue.
是否有任何其他原因可能导致该问题。
First thing IMO is to try to understand where the Finalizer
is coming from - check your libs and try to spot that? IMO 的第一件事是尝试了解
Finalizer
的来源 - 检查您的库并尝试发现它? Maybe they even mention something on their README/docs?也许他们甚至在他们的自述文件/文档中提到了一些东西?
After that, have a look at this answer/question that can give you some insights.之后,看看这个可以给你一些见解的答案/问题。 Also, it sounds to me something related to the GC.
此外,在我看来,这与 GC 相关。 Since you mentioned java 8, you should be using the parallel GC (default one) which is not bad but you can try play with that, change GCs and see if any of the other options works better for you.
由于您提到了 java 8,您应该使用并行 GC(默认),这还不错,但您可以尝试使用它,更改 GC 并查看是否有任何其他选项更适合您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.