From 4fb249239b78a2c223e4b95ccf1e642fdf211c40 Mon Sep 17 00:00:00 2001 From: "shuang.kou" Date: Fri, 6 Mar 2020 08:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E6=99=8B=E5=8D=87?= =?UTF-8?q?=E5=B9=B4=E9=BE=84=E6=98=AF15=E7=9A=84=E8=AF=B4=E6=B3=95?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- ...03\345\234\276\345\233\236\346\224\266.md" | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d763a863b5e..89921e4ba75 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ 更多原创内容和干货分享: 1. [公众号—JavaGuide](#公众号) : 最新原创文章+免费领取本文档配套的《Java面试突击》以及Java工程师必备学习资源) -2. [微信](#联系我) :如果需要和我交流的话可以加我私人微信(ps: 有问题的话也可以问,我会尽量回答大家。我很随和的,哈哈!另外,账号快加满了) +2. [微信](#联系我) :如果需要和我交流的话可以加我私人微信(ps: 有问题的话也可以问,我会尽量回答大家,我很随和的,哈哈!另外,账号快加满了) 3. [B站-Guide哥](https://space.bilibili.com/504390397):(各种干货视频和生活向视频,来个一键三连可好!) 4. [知识星球—JavaGuide读者圈](https://javaguide.cn/2019/01/02/chat/%E5%81%9A%E4%BA%86%E4%B8%80%E4%B8%AA%E5%BE%88%E4%B9%85%E6%B2%A1%E6%95%A2%E5%81%9A%E7%9A%84%E4%BA%8B%E6%83%85/) diff --git "a/docs/java/jvm/JVM\345\236\203\345\234\276\345\233\236\346\224\266.md" "b/docs/java/jvm/JVM\345\236\203\345\234\276\345\233\236\346\224\266.md" index 972e4267484..ad4097c17ec 100644 --- "a/docs/java/jvm/JVM\345\236\203\345\234\276\345\233\236\346\224\266.md" +++ "b/docs/java/jvm/JVM\345\236\203\345\234\276\345\233\236\346\224\266.md" @@ -159,21 +159,24 @@ public class GCTest { > ```c++ > uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) { > //survivor_capacity是survivor空间的大小 -> size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); -> size_t total = 0; -> uint age = 1; -> while (age < table_size) { -> total += sizes[age];//sizes数组是每个年龄段对象大小 -> if (total > desired_survivor_size) break; -> age++; -> } -> uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; +> size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); +> size_t total = 0; +> uint age = 1; +> while (age < table_size) { +> total += sizes[age];//sizes数组是每个年龄段对象大小 +> if (total > desired_survivor_size) break; +> age++; +> } +> uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; > ... > } > > ``` > -> +> 额外补充说明([issue672](https://github.com/Snailclimb/JavaGuide/issues/672)):**关于默认的晋升年龄是15,这个说法的来源大部分都是《深入理解Java虚拟机》这本书。** +> 如果你去Oracle的官网阅读[相关的虚拟机参数](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html),你会发现`-XX:MaxTenuringThreshold=threshold`这里有个说明 +> +> **Sets the maximum tenuring threshold for use in adaptive GC sizing. The largest value is 15. The default value is 15 for the parallel (throughput) collector, and 6 for the CMS collector.默认晋升年龄并不都是15,这个是要区分垃圾收集器的,CMS就是6.** ## 2 对象已经死亡?