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
- It visits only live nodes, it won't bother about unreachable(garbage) nodes.
- It solves the fragmentation problem in Mark-Sweep Approach
Disadvantage
- More memory required to maintain two spaces (Active and unused).
- Long lived objects are copied back and forth for every collector cycle.
No comments:
Post a Comment