Abandoned
objects
If an object is created, but no variable
refers to it, then this object is actually wasting computer memory, since it can never be
used. It is not possible to 'search' through computer memory for objects of a given class
who knows, your program might find part of some word processor document, or part of
a database, stored in memory by some application, and think it was an object
Therefore, once an object is no longer
referred to by any variable of a program, that memory can be though of as available for
some other program to use.
Of course, it is very rare that a situation
might occur where objects would be created and never referred to. However, what is much
more common is that objects get created, refereed to by a variable, used for some purpose,
and then the variable is used to refer to some other object. This is the abandoning of
objects.
When a system needs memory, it can perform a
task called garbage-collection to find all abandoned objects, destroy them (i.e.
call their destructor methods) and free up their memory for other uses.
Back
to top
RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg
|