【发布时间】:2013-09-01 20:46:16
【问题描述】:
据我了解,finalize() 和 GC 是两个不同的方面。 GC 使用 finalize() 方法来释放对象内存。我们无法说明 GC 何时发生(即使我们显式调用 System.gc())。但我们可以显式调用 Object 的 finalize()。
Will the function be executed immediately(memory freed) or it waits till GC
occurs like System.gc() call?
此外,根据文档,Java 虚拟机不会为任何给定对象多次调用 finalize 方法。
所以当我们首先调用 finalize() 并且 GC 发生在稍后的时间点时会发生什么。
If object memory is not freed on explicit call to object.finalize() then would't
it being called again in the GC process violate the calling only once rule?
【问题讨论】:
-
@duffymo 不是真的...
标签: java garbage-collection jvm finalizer