现在的位置: 首页 > 综合 > 正文

1.2.4. Garbage Collection

2017年08月16日 ⁄ 综合 ⁄ 共 2079字 ⁄ 字号 评论关闭

Memory is a shared and limited resource and should not be wasted, particularly in the kernel because it does not use virtual memory. Most kernel subsystems implement some sort of garbage collection to reclaim the memory held by unused or stale data structure instances. Depending on the needs of any given feature, you will find two main kinds of garbage collection:

内存是需要共享的有限资源,不应该被浪费,特别是对内核来说,因为内核模块是不能用虚拟内存的。大部分内核子系统应用某类垃圾回收机制来回收被过时或不再有效的数据实例持有的内存。依赖于功能需求,一般有两种主要的垃圾回收方式:

Asynchronous(异步)

This type of garbage collection is unrelated to particular events. A timer that expires regularly invokes a routine that scans a set of data structures and frees the ones considered eligible for deletion. The conditions that make a data structure eligible for deletion depend on the features and logic of the subsystem, but a common criterion is the presence of a null reference count.
这种类型的垃圾回收并不与特定的事件相关联。一个定时器定时调用一段程序扫描数据结构集合,释放那些被认为适合被删除的数据结构。数据结构符合删除的条件依赖于子系统的功能和逻辑判定。但是一个普遍标准是引用计数变为空

Synchronous(同步)

There are cases where a shortage of memory, which cannot wait for the asynchronous garbage collection timer to kick in, triggers immediate garbage collection. The criteria used to select the data structures eligible for deletion are not necessarily the same ones used by asynchronous cleanup (for instance, they could be more aggressive). See Chapter 33 for an example.
当突发内存短缺,来不及等待异步方式垃圾回收释放资源时,触发器立刻开始做垃圾回收。同步回收判定数据结构可清理的标准并不需要和
异步方式一致(有可能是更有效的)

In Chapter 7, you will see how the kernel manages to reclaim the memory used by initialization routines and that is no longer needed after they have been executed.
-----------------
reclaim  [riˈkleim]                               vt.要回;开垦(荒地);回收
stale  [steil]                                     a.不新鲜的;陈腐的,过时的
asynchronous [ei'siŋkrənəs]                        1.非同期的   2.【电】异步的
expire  [iks'paiə]                                 1.满期,届期;(期限)终止  2.呼气,吐气 3.【书】断气,死亡
invoke  [inˈvəuk]                                 vt.恳求 唤起;引起;造成 ,诉诸
eligible  [ˈelidʒəbəl]                            a.有条件被选中的;(尤指婚姻等)合适(意)的
criterion  [kraiˈtiəriən]                         n.(批评、判断等的)标准,准则
presence  [ˈprezəns]                              n.出席,到场,存在;仪表,仪态
trigger  [ˈtrigə]                                n.扳机;引起反应的行动 vt.触发,引起
aggressive  [əˈgresiv]                           a.侵犯(略)的,挑衅的;敢做敢为的

 

抱歉!评论已关闭.