June 2002
Intermediate to advanced
504 pages
10h 10m
English
The Java garbage collection mechanism usually frees unused objects automatically. “Unused” from the point of view of the garbage collector means that the objects are not referenced from somewhere else. If objects are no longer needed in a program, but are still referenced by a variable or indirectly by another object, the garbage collector can't determine that the object can be removed, and the corresponding memory is not reclaimed. Thus, if an object is allocated and then no longer needed, but the variable holding the object is still in the valid scope, it may make sense to set the variable to null explicitly. For example, if a buffer is allocated at the beginning of a method, but then no longer needed ...
Read now
Unlock full access