开发者

Finalization queue in Java

开发者 https://www.devze.com 2023-03-28 16:46 出处:网络
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

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 Wh开发者_StackOverflow中文版en 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.


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?

Almost. It says that objects whose superclasses have implemented "finalize" are added to the finalization queue when the garbage collector finds them unreachable.

0

精彩评论

暂无评论...
验证码 换一张
取 消