Java GC: why two survivor regions?

前端 未结 7 1493
旧巷少年郎
旧巷少年郎 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:27

    Young Generation : It is place where lived for short period and divided into two spaces:

    Eden space : New objects will be allocated in the memory pool. The assumption is that most object get dereferenced and become unreachable soon after their creation. Objects not being dereferenced will be copied by the new generation garbage collector into the survivor spaces. They may get copied n some special cases directly into the old generation pool.

    Survivor spaces: These two small spaces keep the surviving objects of a young generation garbage collection. Surviving objects will be copied for a (small) number of times from one survivor into the other. This allows to harvest our more dereferenced objects.

    Old generation: The largest memory pool which should keep the long living objects. Objects are getting copied into this pool once they leave the survivor spaces.

    Permament generation: This fairly unknown pool keeps the information of all the classes. It doesn't need any attention for most applications. It may need to be adapted for some applications with many classes. It may need some attentention as well if the application permanently loads and unloads classes.

    Other advantages:

    • Memory fragmentation
    • It improves GC performance

    Please find the following links for more details which can help you understand more

    http://www.scalingbits.com/javaprimer

    http://java.sys-con.com/node/84695

提交回复
热议问题