Java Reference
In-Depth Information
for you because an object that's still referenced somewhere will never
be garbage-collected and so will never be considered free. Garbage col-
lection also solves the problem of accidentally deleting an object mul-
tiple timessomething that can also cause havoc.
Garbage is collected without your intervention, but collecting garbage
still takes work. Creating and collecting large numbers of objects can in-
terfere with time-critical applications. You should design such systems
to be judicious in the number of objects they create and so reduce the
amount of garbage to be collected.
Garbage collection is not a guarantee that memory will always be avail-
able for new objects. You could create objects indefinitely, place them in
lists, and continue doing so until there is no more space and no unrefer-
enced objects to reclaim. You could create a memory leak by, for ex-
ample, allowing a list of objects to refer to objects you no longer need.
Garbage collection solves many, but not all, memory allocation prob-
lems.
 
Search WWH ::




Custom Search