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...
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.
Personally, I feel that S0 and S1 exist to improve performance.
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...
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.
After each GC, the two Survivors will swap positions
The only thing I know so far is how to do it
Used to prevent the generation of debris, this is the legendary buddy system.