13-04 Understanding Object Generations
To help optimize the process, each object on the heap is assigned to a specific “generation.” The idea behind generations is simple: the longer an object has existed on the heap, the more likely it is to stay there.
为了帮助优化这个流程,堆中的每个对象都被赋予'generation'这个概念。'generation'这个概念也非常简单,对象在堆中存在的越长,就越可能呆着那里。
Generation 0: Identifies a newly allocated object that has never been marked for collection.
Generation 1: Identifies an object that has survived a garbage collection (i.e., it was marked for collection but was not removed due to the fact that the sufficient heap space was acquired).
Generation 2: Identifies an object that has survived more than one sweep of the garbage collector.
The garbage collector will investigate all generation 0 objects first. If marking and sweeping (or said more plainly, getting rid of) these objects results in the required amount of free memory, any surviving objects are promoted to generation 1.
GC首相要调查所有0代的对象,如果标记并且清扫这些对象来得到这些空间内存,任何幸存的对象讲被提升为1代。

浙公网安备 33010602011771号