Skip to content

Commit

Permalink
默认的晋升年龄是15的说法完善
Browse files Browse the repository at this point in the history
  • Loading branch information
Snailclimb committed Mar 6, 2020
1 parent a8251a8 commit 4fb2492
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)

Expand Down
23 changes: 13 additions & 10 deletions docs/java/jvm/JVM垃圾回收.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 对象已经死亡?
Expand Down

0 comments on commit 4fb2492

Please sign in to comment.