全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Generational collection, write barrier, remembered set?

又称: generational collection · remembered set · write barrier

Definition 9.9 University Computer Science — Year 3 · 第 9 章 — Memory Management and Garbage Collection

A generational collector allocates in a small nursery and collects it alone in a minor collection, which moves its survivors into an old generation (promotion); a major collection collects the whole heap. The remembered set holds the old objects that may refer to nursery objects; a minor collection treats them as roots. A write barrier is code run at every store of a reference into an object; here, it adds the object to the remembered set when an old object receives a reference to a young one.

Two generations. The store of a reference to the young cell y into the old cell s goes through the write barrier, which adds s to the remembered set. The next minor collection starts from the roots and from s, so it promotes y; the grey cell, which nothing refers to, is never examined.
Two generations. The store of a reference to the young cell yy into the old cell ss goes through the write barrier, which adds ss to the remembered set. The next minor collection starts from the roots and from ss, so it promotes yy; the grey cell, which nothing refers to, is never examined.
在原文中阅读 →