Garbage Collection

September 10, 2007 at 11:45 am (Compilers and Virtual Machines)

Garbage Collection is a mechanism through which a compiler takes care of unreferenced allocations off the heap. A garbage collection routine mainly fires up when the heap gets filled or small chunks are left. Here are some of the types of collectors.

Reference Counting – Some data is maintained for each allocation. This includes a counter which takes the total number of references to it. A collector runs periodically and collects all allocations with count zero.

Concurrent – This collector runs one thread of application for collection. In this way we don’t need to wait for the collection. Stopping of applications is done only when the collector thread is initialized.

Mark And Sweep – One of the most popular collector in which the referenced pointers are marked and rest of the allocations are sweeped out or collected. This needs stopping of all processes.

Mark Compact -This technique adds the compaction after sweeping to cover probs of external fragmentation.

Copying Collector – This is and advancement for mark and sweep. This type of collector copies the marked allocations to the different space and collects all of previous once all copying is done.

Parallel Copying CollectorThe parallel copying collection is a version of copying collection that runs as many threads as there are CPUs, preventing the workload from being restricted to only one CPU. The standard copying collection is unable to spread the workload to different processors, which creates an unnecessary bottleneck in performance.

Generational Collector – This is a scheme of collection for controlling frequency. Generations of collections are made which are usually heap space division. Each generation may have different collector. Allocations are transferred to the older generation if they survive through a defined number of collections. The collector for older generation runs less frequently than younger one. Java uses 2 generations for its work and .Net compiler has 3 generations.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: