iEntry 10th Anniversary Cloud Computing Certification
Newsletter Archive Article Archive Submit Article Advertising Info About Us Contact

How To Use Garbage Data Collectors

Vaibhav Pandey Posted by Vaibhav Pandey

A Garbage Collector must do two things:-

1.Detect garbage objects
2.Deallocate the memory of garbage objects and make it available for the program.

There are four approaches that a garbage collector may adopt to detect the garbage objects.

A) Reference -counting Collectors :-Reference counting garbage collectors keep a count of the references for the each live object.When an object is created ,the reference count of each object is set to one.When you reference the object ,the reference count is incremented by one.Similarly when a reference to an object is eliminated ,the reference count is decremented by one.An object which has reference count zero is a garbage object when the object is garbage collected ,the references of the object that it refers to are decremented.Therefore garbage collection of the one may lead to the creation of other garbage objects.This method can be executed in small parts with the program ,and the program need not to be interrupted for a long time. However ,there is an overhead of incrementing and decrementing the counter everytime something happens on the references side.

B) Tracing Collectors :-In this technique ,a set of root is defined from where objects are traced. An object is reachable if there are objects that referenced and cannot ,therefore be accessed in the program.Objects that are reachable are marked. At the end of the trace ,all marked objects can be garbage collected.
This is also known as the mark and sweep algorithm. The mark phase marks all the referenced objects. The sweep phase garbage collects the memory of unreachable and unreferenced objects.

C) Compacting Collectors :-These collectors reduce the degree of memory fragmentation by moving the all unused and free space on one side during garbage collection.The free memory is then available as one huge chunk.All references need to be shifted ,objects are the updated to refer to the new memory locations.

D)Adaptive Collectors :-This algorithm makes the use of the fact that different garbage collectors algorithm works better in different situations. The adaptive algorithm monitors the situation and uses the garbage technique that best suits the situation. It may switch from one technique to the other according to the need.

Comments

About the Author: Vaibhav Pandey got offered employment from an Indian Multinational IT Company. He is 21 years old. He has a huge interest in Java programming and has liked it from his study days. Vaibhav loves to blog and share his experiences and thoughts. He now resides in Lucknow, a state capital in India. Check out his blog at http://javatutorialsworld.blogspot.com.

Leave a Reply

Free Tools & Tips Emailed To You

ITCertificationNews
ClicksToday
MarketingNewz

Send me relevant info on products and services.


Get Your Site Submitted for Free in the
World's Largest B2B Directory!

*
*
*Indicates Mandatory Field

Terms & Conditions
Newsletter Archive | Article Archive | Submit Article | Advertising Info | About Us | Contact
ITCertificationNews is an iEntry Network ® publication - 1998-2009 All Rights Reserved Privacy Policy and Legal