作者:蓬从蓉Tahirah | 来源:互联网 | 2023-10-10 10:28
Ihaveamisbehavingapplicationthatseemstoleak.Afterabriefprofilerinvestigation,mostmemo
I have a misbehaving application that seems to leak. After a brief profiler investigation, most memory (80%) is held by java.lang.ref.Finalizer
instances. I suspect that finalizers fail to run.
我有一个行为不当的应用程序,似乎泄露了。经过简短的分析器调查,大多数内存(80%)由java.lang.ref保存。终结器实例。我怀疑终结器不能运行。
A common cause of this seems to be exceptions thrown from the finalizer. However, the javadoc for the finalize
method of the Object
class (see here for instance) seems to contradict itself: it states
一个常见的原因似乎是终结器抛出的异常。但是,对象类的finalize方法的javadoc(例如在这里看到)似乎自相矛盾:它声明
If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
如果finalize方法抛出未捕获的异常,则会忽略该异常,该对象的终结。
but later, it also states that
但后来,它也指出了这一点
Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.
finalize方法抛出的任何异常都会导致该对象的终结,但在其他情况下会被忽略。
What should I believe (i.e., is finalization halted or not?), and do you have any tips on how to investigate such apparent leaks?
我应该相信什么?你对如何调查这些明显的泄漏有什么建议吗?
Thanks
谢谢
5 个解决方案