A method and a system for facilitating garbage collection (GC) operations
in a memory-management system that supports both mark-sweep (MS) objects
and reference-counted (RC) objects, wherein objects which are frequently
modified are classified as MS objects, and objects which are infrequently
modified are classified as RC objects. During a marking phase of a GC
operation, the system identifies a set of root objects and then marks
referents of the root objects. The system then recursively traverses
referents of the root objects which are MS objects and while doing so,
marks referents of the traversed MS objects. However, if an RC object is
encountered during the traversal of an MS object, the system marks the RC
object but does not recursively traverse the RC object. In doing so, the
system avoids traversing a large number of RC objects which are
infrequently modified.