search

Home  >  Q&A  >  body text

java - 为什么JVM中新生代有两个Survivor区?

为什么JVM中新生代有两个Survivor区?

如题。

伊谢尔伦伊谢尔伦2840 days ago885

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:00:39

    Personally, I feel that S0 and S1 exist to improve performance.

    Usage of survivor space:

    At any time, there is always one survivor space that is empty. During the next copying collection, eden and the live objects in another survivor space will be copied to this space.
    Live objects are copied back and forth between the two survivor spaces until the objects are old enough and can be placed in the tenured generation (copy the past)

    Because dead objects need to be cleaned up during garbage collection. If there is only one survivor area, then the dead objects in this survivor area will generate memory fragments after being cleaned up. In order to avoid memory fragmentation, the live object must be moved. Go, you will lose performance.

    If there are two survivor areas, according to the above statement, there will be no problem of memory fragmentation.

    SO's answer is here: http://stackoverflow.com/ques...

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:00:39

    The new generation uses 复制收集算法,两个Survivor区是为了配合复制收集算法.
    I introduced this type of problem in detail in one of my blogs. If you are interested, you can take a look.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:00:39

    After each GC, the two Survivors will swap positions
    The only thing I know so far is how to do it

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:00:39

    Used to prevent the generation of debris, this is the legendary buddy system.

    reply
    0
  • Cancelreply