<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

     StackOverflow上面給出的解釋是:

    The reason for the HotSpot JVM's two survivor spaces is to reduce the need to deal with fragmentation. New objects are allocated in eden space. All well and good. When that's full, you need a GC, so kill stale objects and move live ones to a survivor space, where they can mature for a while before being promoted to the old generation. Still good so far. The next time we run out of eden space, though, we have a conundrum. The next GC comes along and clears out some space in both eden and our survivor space, but the spaces aren't contiguous. So is it better to

    1. Try to fit the survivors from eden into the holes in the survivor space that were cleared by the GC?
    2. Shift all the objects in the survivor space down to eliminate the fragmentation, and then move the survivors into it?
    3. Just say "screw it, we're moving everything around anyway," and copy all of the survivors from both spaces into a completely separate space--the second survivor space--thus leaving you with a clean eden and survivor space where you can repeat the sequence on the next GC?

    Sun's answer to the question is obvious.


      對于如何達到“無碎片”的目的,理解上可能有些困難,下面我把新生代回收機制詳細解釋一下:

      注意,兩個survivor是交替使用的,在任意一個時刻,必定有一個survivor為空,一個survivor中存放著對象(連續存放,無碎片)。回收過程如下:

      S1、GC,將eden中的live對象放入當前不為空的survivor中,將eden中的非live對象回收。如果survivor滿了,下次回收執行S2;如果survivor未滿,下次回收仍然以S1的方式回收;

      S2、GC,將eden和存放著對象的survivor中的live對象放入當前為空的survivor中,將非live對象回收。

      可以看到,上述的新生代回收機制保證了一個survivor為空,另一個非空survivor中無碎片。

      在執行一定次數的minor GC后,會通過Full GC將新生代的survivor中的對象移入老年代。


      對于理解GC的整個機制,推薦一篇非常好的文章http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection/

    posted on 2014-12-09 14:16 abin 閱讀(1026) 評論(0)  編輯  收藏 所屬分類: JVM
    主站蜘蛛池模板: 在线观看免费无码视频| 亚洲国产精品综合福利专区| 亚洲中文字幕无码亚洲成A人片| 久久成人免费播放网站| 亚洲无码日韩精品第一页| 国产亚洲福利精品一区二区| 免费精品国产自产拍在线观看图片| 亚洲欧洲第一a在线观看| 国产精品免费看久久久| 久久精品国产亚洲精品2020| 精品一区二区三区无码免费视频 | 久久精品国产亚洲AV不卡| 免费国产黄网站在线看| 亚洲成av人片不卡无码久久| 国产免费MV大全视频网站| 亚洲成av人在线视| 在线观看免费av网站| 亚洲av成人一区二区三区| 国产精品自在自线免费观看| 三级片免费观看久久| 久久精品国产亚洲香蕉| 日韩在线播放全免费| 亚洲精品久久久久无码AV片软件| 亚洲成A∨人片天堂网无码| 免费网站观看WWW在线观看| 久久久久亚洲av无码专区| 成人性生交大片免费看无遮挡| 亚洲Aⅴ在线无码播放毛片一线天| 亚洲成a人一区二区三区| 久久精品免费电影| 四虎亚洲精品高清在线观看| 四虎永久免费地址在线观看| 免费无码又爽又刺激一高潮| 亚洲伊人久久大香线蕉AV| 亚洲无码日韩精品第一页| 精品成在人线AV无码免费看| 春暖花开亚洲性无区一区二区| 国产AV无码专区亚洲A∨毛片| 永久免费AV无码国产网站| 丁香六月婷婷精品免费观看| 精品亚洲aⅴ在线观看|