are equivalent to the calls
loader.setClassAssertionStatus("com.acme.Evaluator", false);
loader.setPackageAssertionStatus("com.acme", true);
where loader is the class loader that will be used. (Note that the methods do not use the ... syntax that the
command line uses because it is apparent whether a name refers to a package or a class.)
Be and not seem.
Ralph Waldo Emerson
Chapter 17. Garbage Collection and Memory
Civilization is a limitless multiplication of unnecessary necessaries.
Mark Twain
The Java virtual machine uses a technique known as garbage collection to determine when an object is no
longer referenced within a program, and so can be safely reclaim466466ed to free up memory space. This
chapter teaches the basic ideas behind garbage collection, how the programmer can be involved in the garbage
collection process, and how special reference objects can be used to influence when an object may be
considered garbage.
17.1. Garbage Collection
Objects are created with new, but there is no corresponding delete operation to reclaim the memory used
by an object. When you are finished with an object, you simply stop referring to itchange your reference to
refer to another object or to null, or return from a method so its local variables no longer exist and hence
refer to nothing. Objects that are no longer referenced are termed garbage, and the process of finding and
reclaiming these objects is known as garbage collection.
The Java virtual machine uses garbage collection both to ensure any referenced object will remain in memory,
and to free up memory by deallocating objects that are no longer reachable from references in executing code.
This is a strong guaranteean object will not be collected if it can be reached by following a chain of references
starting with a root reference, that is, a reference directly accessible from executing code.
In simple terms, when an object is no longer reachable from any executable code, the space it occupies can be
reclaimed. We use the phrase "can be" because space is reclaimed at the garbage collector's discretion, usually
only if more space is needed or if the collector wants to avoid running out of memory. A program may exit
without running out of space or even coming close and so may never need to perform garbage collection. An
object is "no longer reachable" when no reference to the object exists in any variable of any currently
executing method, nor can a reference to the object be found by starting from such variables and then
following each field or array element, and so on.
Garbage collection means never having to worry about dangling references. In systems in which you directly
control when objects are deleted, you can delete an object to which some other object still has a reference.
That other reference is now dangling, meaning it refers to space that the system considers free. Space that is
thought to be free might be allocated to a new object, and the dangling reference would then reference