What is a Garbage Collector? How it is Used?
Posted by admin on August 3, 2006 Leave a comment (0) Go to comments
Again, this is a very basic, but detailed question about object oriented languages. You may also be asked to describe the advantages and disadvantages of using garbage collector, or how it is used in a specific language such as C++ or Java. Here I just give you some basic concepts of garbage collector:
Why garbage collector is needed? – When an object is no longer referenced by another object, then it is necessary to reclaim the system resources such as cache memory previously allocated by this object. A garbage collector periodically scans the active object space for objects no longer being referenced and released the system resources for any such objects.
Advantages – This automatic process relieves the application programmer from the duties of freeing objects that are no longer needed. This represents a substantial saving in the amount of detailed, low-level programming that the programmer must do.
Disadvantages – The garbage collection process is typically not under control of the application. This can lead to unpredictable delays in processing.