Saturday, 19 July 2014

Copying Collectors

In this mechanism, Heap is divided into two equal spaces. One space contains all the active data used by your application, and other space left unused. When the active space fills up, then all the reachable(live) objects are identified and copied from active space to unused space. Now the roles of the memory spaces are interchanged. I.e, unused space acts as active space and active space acts as unused space. After the copying is done from active space to unused space, then the memory in active space is freed.

Advantages
  1. It visits only live nodes, it won't bother about unreachable(garbage) nodes.
  2. It solves the fragmentation problem in Mark-Sweep Approach
Disadvantage
  1. More memory required to maintain two spaces (Active and unused).
  2. Long lived objects are copied back and forth for every collector cycle.



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment