来自 oracle gc 调优文章 1和文章 2:
幸存者空间大小
您可以使用该参数SurvivorRatio来调整幸存者空间的大小,但这通常对性能并不重要。例如, -XX:SurvivorRatio=6将伊甸园和幸存者空间之间的比率设置为 1:6。
In other words, each survivor space will be one-sixth the size of eden, and thus one-eighth the size of the young generation (not one-seventh, because there are two survivor spaces).
如果幸存者空间太小,复制集合会直接溢出到终身代。如果幸存者空间太大,它们将是无用的空。
NewSize和MaxNewSize参数控制新一代的最小和最大尺寸。通过将这些参数设置为相等来调节新生代的大小。The bigger the younger generation, the less often minor collections occur.
NewRatio:新生代相对于老年代的大小由NewRatio控制。例如,设置-XX:NewRatio=3表示老年代和年轻代的比例为1:3,the combined size of eden and the survivor spaces will be fourth of the heap。
正如正确引用的那样Peter Lawrey,设置幸存者取决于您的应用程序的类型。来自 Oracle 的 gc 调整文章,这里是指导方针。
First decide the maximum heap size you can afford to give the virtual machine. 然后将你的性能指标与年轻代的大小进行对比,以找到最佳设置
If the total heap size is fixed, then increasing the young generation size requires reducing the tenured generation size. 保持老年代足够大,以容纳应用程序在任何给定时间使用的所有实时数据,以及一些松弛空间(10% 到 20% 或更多)。
受制于前面对终身代的约束:向年轻代授予大量内存,并且increase the young generation size as you increase the number of processors, because allocation can be parallelized. 默认值是根据NewRatio和-Xmx设置计算的