Java 中的终结队列
是否只有当类具有 Finalize() 方法时,只有当该对象无法访问时才会将其添加到终结队列中?原因是我正在浏览这个链接 在子类化时避免内存保留问题类别中,它表示在调用finalize()
之前,大数组不可用于垃圾回收。 但我的观点是,即使我不编写 Finalize() 方法,它仍然必须等待对象在终结队列中出队。
Is it the case that only if a class has a finalize()
method, only then that object, when unreachable, is added to the finalization queue? Reason being I was going through this link
and in the category Avoid Memory-Retention Problems When Subclassing it says that a large array is not available for garbage collection till finalize()
is called.
But my point is that even if I don't write a finalize()
method, still it had to wait for the object to be deque'd in the finalization queue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几乎。它表示,当垃圾收集器发现其超类已实现“finalize”的对象无法访问时,这些对象将被添加到终结队列中。
Almost. It says that objects whose superclasses have implemented "finalize" are added to the finalization queue when the garbage collector finds them unreachable.