Java GC: why two survivor regions?

前端 未结 7 1470
旧巷少年郎
旧巷少年郎 2020-12-04 06:15

For Sun/Oracle\'s JVM, I\'ve read that the GC algo divides new generation into one Eden region and two survivor regions. What I\'m wondering about is, why two survivor regio

7条回答
  •  情深已故
    2020-12-04 06:18

    All the current answer talk about memory fragmentation, this is also another reason to have generations in GC.

    The runtime records all “old objects” that point to “new objects”, this is done every time a “pointer” field is updated. Then when a “minor” GC is done, only “new” objects need to be scanned.

    Over the years it has been found that just have “new” and “old” is not enough, and it is good to have a 3rd generation that is “middle aged”.

提交回复
热议问题