Why is heap divided into Eden, Survivor spaces and Old Generation?

前端 未结 2 1619
醉梦人生
醉梦人生 2020-12-18 04:43

Could you please answer me a question about JVM Garbage Collection process?

Why is heap divided into Eden, Survivor spaces and Old Generation?

When a young e

2条回答
  •  眼角桃花
    2020-12-18 05:22

    The division is very useful if you consider moving collectors. If there were no separation a young collection would leave a lot of holes in the heap, requiring either free list management or compaction of the old gen.

    If on the other hand the young generation is implemented as a semi-space GC no such cleanup and tracking is required because the evacuated space will by definition only contain dead objects after a minor collection and can thus be considered free space afterwards. This also enables bump pointer allocation in the young gen.

提交回复
热议问题