Reference-Counting Collectors
Tracing Collectors
Compacting Collectors
Reference-Counting Collectors
Reference-Counting garbage collectors store the references of the objects used within a program. The concept works as follows: You create a reference A that points to a particular object ABC. You create one more reference B that points to object XYZ. Next, you assign one more reference C to first object ABC. As you make references to object(s), the reference count is incremented by one and when you remove references for the same object, the reference count is decremented by one. When you remove all references to ABC object, then reference count for this object is set to ZERO. All objects with ZERO references are marked for garbage collection.
An object that has a reference count of zero is not referenced in a program and is a garbage object. When the object is identified as garbage, the reference count of ail the objects that it refers to is decremented. Therefore, garbage collection of one object can lead to creation of more garbage objects.
The garbage collection method can be executed in small parts within a program and the program need not be interrupted for a long time. An overhead occurs whenever the counters are Incremented or decremented.
Tracing Collectors
In this technique, a set of roots is defined from the location where the objects are traced. An abject is reachable if there are objects that reference it. The objects that are not reachable are considered garbage objects since they are not referenced and are not accessed within a program. The tracing collectors mark the objects that are reachable. At the end of the trace, all unmarked objects are identified as garbage.
Tracing Collector is also known as the mark-and-sweep algorithm. The mark phase marks al the referenced objects. The sweep phase garbage collects the unreferenced objects.
Compacting Collectors
Compacting collectors reduce the fragmentation of memory by moving the free space to one side during garbage collection. The free memory is then available to be used by other objects. All references to the shifted objects are then updated to point to new memory locations
Published by Harsh Gupta - Tech Writer
I am a part time freelancer and writing is my hobby Some of my websites: http://www.GenericArticles.com http://www.JailBreakingiPhone.com View profile
This is Not Our Father's GarbageGarbage is piling up in America. What have we been doing about it? What else can be done?- Toronto Garbage Strike - a Chance to Re-evaluate How We Handle Our WasteToronto is buried under tons of garbage. Let's use this opportunity to try and reduce the amount of waste we produce.
- So What If They Can Go Through Your Garbage?A quick look at the new precedent setting Canadian Supreme Court case.
Garbage Crisis Leaves Naples' Streets a Putrid MessOfficials fear health crisis and environmental hazards if streets are not cleared of rubbish.- What Makes a Memory Foam Mattress Different from a Regular Mattress?Examines what makes a memory foam mattress unique and desirable over traditional mattresses.
- Understanding Java
- Mango Glut in Brisbane, Australia Causes Garbage Collection Chaos
- The Secret to Understanding Objects in Java
- Garbage Men and Their Truck
- Difference Between Java and C Plus Plus (C++)
- Your Garbage is Your Identity
- Learn Urban Cities in One Sitting
- Garbage collection is the process that is used to free the memory of the objects that are no longer
- When a program stops referencing an object, it is not required anymore and can be deleted. The

1 Comments
Post a CommentInteresting item.