Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: the link to JLS(12.6.2) fixed.

...

  • The JVM may terminate without invoking the finalizer on some or all unreachable objects. Consequently, attempts to update critical persistent state from finalizer methods can fail without warning. Similarly, Java lacks any guarantee that finalizers will execute on process termination. Methods such as System.gc(), System.runFinalization(), System.runFinalizersOnExit(), and Runtime.runFinalizersOnExit() either lack such guarantees or have been deprecated because of lack of safety and potential for deadlock.
  • Wiki Markup
    According to the _Java Language Specification_, [
    §12
    §12.6.2, "Finalizer Invocations are Not Ordered
    |"[JLS 2005]
    "|http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.6.2] \[[JLS 2005|AA. Bibliography#JLS 05]\]:

    Wiki Markup
    The Java programming language imposes no ordering on {{finalize()}} method calls. Finalizers \[of different objects\] may be called in any order, or even concurrently.

    One consequence is that slow-running finalizers can delay execution of other finalizers in the queue. Further, the lack of guaranteed ordering can lead to substantial difficulty in maintaining desired program invariants.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7250bdde3bfdaf3a-5511ef3e-45e94d0b-8d3a84af-fc2ed61c4793eff771819e95"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

[finalize()

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#finalize()]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="612b26d61a4adc30-4cc4cde3-44824bba-a63fabc5-73a518e907b6908ee0c09ebc"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 7. Avoid finalizers

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="44f0fa35fbddb99d-da1d6bf2-4af44313-bfcfaf02-27db0467606577fe3b222959"><ac:plain-text-body><![CDATA[

[[Boehm 2005

AA. Bibliography#Boehm 05]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1ff28d3729dab06e-f4ee116e-40a44afe-a21badd0-de5bcb9fa1023211a33948ee"><ac:plain-text-body><![CDATA[

[[Coomes 2007

AA. Bibliography#Coomes 07]]

"Sneaky" Memory Retention

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7a8bb3c25b54d757-6c33d83d-43fb43a2-997facb2-5b1ec9ff5712a364298e6bc0"><ac:plain-text-body><![CDATA[

[[Darwin 2004

AA. Bibliography#Darwin 04]]

Section 9.5, The Finalize Method

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ab8c7ce74783131c-9bf79485-45e946c5-a3909f3c-6111a15f2143c9369bf9ed9a"><ac:plain-text-body><![CDATA[

[[Flanagan 2005

AA. Bibliography#Flanagan 05]]

Section 3.3, Destroying and Finalizing Objects

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="80a131dda052685b-ca87a0d1-4742454b-91b3a987-c6bd6b8df0960a93c519c92e"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

§12.6, Finalization of Class Instances

]]></ac:plain-text-body></ac:structured-macro>

...