The GC (Garbage Collection) will send some sort of finalize message to the object and then set any weakly-referencing variables to null whenever it disposes of the referenced object. This allows finalization logic to be run before the object is disposed of (e.g., close a file if still open, commit any open transaction(s), etc.). Java version 1.1 does not support weak references other than via an undocumented Ref class that is not supported under Netscape. Weak references arrived officially with JDK (Java Development Kit) 1.2. Java has three kinds of weak references, called soft references, weak references and phantom references, in order of increasing weakness.Java has four orders of strength in holding onto Objects. In descending order from strongest to weakest they are:
|Soft vs Weak vs Phantom References
|An ordinary reference. Keeps objects alive as long as they are referenced.
|Any object not pointed to can be reclaimed.
|Keeps objects alive provided there’s enough memory.
|to keep objects alive even after clients have removed their references (memory-sensitive caches), in case clients start asking for them again by key.
|After a first gc pass, the JVM decides it still needs to reclaim more space.
|Keeps objects alive only while they’re in use (reachable) by clients.
|Containers that automatically delete objects no longer in use.
|After gc determines the object is only weakly reachable
|Lets you clean up after finalization but before the space is reclaimed (replaces or augments the use of finalize())
|Special clean up processing
This page is posted
Optional Replicator mirror
Your face IP:[220.127.116.11]
You are visitor number