A method and apparatus are provided for the efficient management of remembered sets in a generational garbage collection scheme. The present invention detects when an old object has a pointer to a young object, and needs to be added to the remembered set. A write buffer and a temporary buffer are used to create and maintain the remembered set. Entries in the write and temporary buffers are used as part of the root set for creating the remembered set for the next garbage collection. A barrier bit associated with each object differentiates generations in the generational garbage collection scheme and is used to determine whether to make an entry into a write buffer when a reference to another object is stored into an object. Objects that have survived one or more collections, but not the minimum number, N, of collections to be considered an old object are referred to as “middle-aged” objects. During a minor garbage collection, the write buffer is scanned. Objects identified in the write buffer are transferred to the remembered set for the next cycle if the object is (i) an old object pointing to a younger object, or (ii) a middle-aged object that is determined to be live. Middle-aged objects identified in the write buffer that are not yet known to be live are transferred to the temporary buffer. At the end of the minor collection, the temporary buffer is processed and objects that are then known to be live are transferred into the remembered set.
展开▼