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

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

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

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      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.


      對(duì)于如何達(dá)到“無(wú)碎片”的目的,理解上可能有些困難,下面我把新生代回收機(jī)制詳細(xì)解釋一下:

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

      S1、GC,將eden中的live對(duì)象放入當(dāng)前不為空的survivor中,將eden中的非live對(duì)象回收。如果survivor滿了,下次回收?qǐng)?zhí)行S2;如果survivor未滿,下次回收仍然以S1的方式回收;

      S2、GC,將eden和存放著對(duì)象的survivor中的live對(duì)象放入當(dāng)前為空的survivor中,將非live對(duì)象回收。

      可以看到,上述的新生代回收機(jī)制保證了一個(gè)survivor為空,另一個(gè)非空survivor中無(wú)碎片。

      在執(zhí)行一定次數(shù)的minor GC后,會(huì)通過Full GC將新生代的survivor中的對(duì)象移入老年代。


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

    posted on 2014-12-09 14:16 abin 閱讀(1021) 評(píng)論(0)  編輯  收藏 所屬分類: JVM
    主站蜘蛛池模板: 亚洲av片在线观看| 最近2019免费中文字幕视频三| 亚洲精品乱码久久久久久按摩| 99热这里只有精品6免费| 国产精品亚洲一区二区麻豆| 亚洲人成电影在线播放| 日本免费xxxx色视频| 一级a性色生活片久久无少妇一级婬片免费放 | 亚洲人成网站色在线观看| gogo全球高清大胆亚洲| 67pao强力打造高清免费| 看成年女人免费午夜视频| 色拍自拍亚洲综合图区| 亚洲Av无码乱码在线观看性色| 最刺激黄a大片免费网站| 午夜免费国产体验区免费的| 久久久亚洲裙底偷窥综合| 亚洲国产成人a精品不卡在线| 最近最好最新2019中文字幕免费 | 最刺激黄a大片免费网站| 白白色免费在线视频| 亚洲精品国产专区91在线| 青青草原亚洲视频| 处破痛哭A√18成年片免费| 你是我的城池营垒免费看| 亚洲av无码兔费综合| 亚洲成人黄色在线观看| 亚洲精品国产精品乱码不99 | 日韩视频在线精品视频免费观看| 五月天国产成人AV免费观看| 亚洲综合精品第一页| 久久久久亚洲AV成人片| 国产亚洲无线码一区二区| 国产黄色片在线免费观看| 日本妇人成熟免费中文字幕| 国产成人精品免费久久久久| 成人毛片100免费观看| 日本视频免费观看| 自拍偷自拍亚洲精品播放| 亚洲综合激情五月色一区| 亚洲AV无码一区二区三区在线|