[Note][深入理解Java虚拟机] 第三章 垃圾收集器与内存分配策略笔记

书上关于GCTimeRatio的讲解有点难以理解,查看Oracle的文档后重新理解了下
-XX:GCTimeRatio 运行时间 / GC时间

当GCTimeRatio为19时,运行时间是GC时间的19倍,也就是GC时间不能超过 1 / (1 + 19) = 0.05

附上Oracle的文档原文

-XX:GCTimeRatio=nnn
A hint to the virtual machine that it's desirable that not more than 1 / (1 + nnn) of the application execution time be spent in the collector.
For example -XX:GCTimeRatio=19 sets a goal of 5% of the total time for GC and throughput goal of 95%. That is, the application should get 19 times as much time as the collector.

By default the value is 99, meaning the application should get at least 99 times as much time as the collector. That is, the collector should run for not more than 1% of the total time. This was selected as a good choice for server applications. A value that is too high will cause the size of the heap to grow to its maximum.

Reference

  1. Garbage Collector Ergonomics