Java堆中的空间/世代之间的比率是不变的? [英] Are ratios between spaces/generations in the Java Heap constant?

查看:120
本文介绍了Java堆中的空间/世代之间的比率是不变的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读这篇文章关于虚拟机垃圾收集调优以更好地理解Java垃圾收集器。每个空间都有一个虚拟堆空间区域,随着堆空间需要更接近最大堆大小,它可以增长。这可以在这张图中看到:
Java GC世代安排http://www.oracle.com/ocom/groups/public/@otn/documents/digitalasset/190244.gif



您可以使用 NewRatio 参数设置年轻一代旧(年龄)代之间的比率,以及 Eden Space Survivor Space 带有 SurvivorRatio 参数。 最近这个问题被问及如何找出堆空间的默认比率。它说你应该使用 PrintGCDetails 参数并手动计算比率。



我的问题是:不同堆空间的大小是否增加相同的比率,因此在应用程序的整个运行期间,它们之间的比率在启动时保持不变?例如,如果Young Generation和Old / Tenured Generation的默认NewRatio为3,Young的初始保留堆空间为100 MB,Old为300 MB。如果需要为旧空间预留更多内存,可以说300MB以上,总共600MB。预留给Young Space的内存是否也会增加到200MB以保持比例不变?我认为你指的是 GC人体工程学自适应尺寸策略

strong>




  • Hotspost GC的一项功能,可在运行时自动调整世代的尺寸 基于正在运行的应用程序的当前分配行为。

  • 此功能默认为ON,并在运行时控制/调整世代的大小。 实际上,一些 GC参数将被忽略,如果您不禁用自适应大小策略,例如。 -XX:SurvivorRatio =



您可以禁用通过使用 -XX:-UseAdaptiveSizePolicy 来实现自适应尺寸策略。一旦禁用了AdaptiveSizePolicy,GC将按照启动参数(例如 -Xms -Xmx -XX:MaxNewSize = -XX:NewSize = -XX:SurvivorRatio = ),它们将保持不变。

你可以在使用AdaptiveSizePolicy和其他jvm选择


I have read this article about virtual machine garbage collection tuning to understand the java garbage collector better. Each space has a Virtual heap space area which it can grow into as the heap space needed gets closer to the max heap size. This can be seen in this picture: Java GC arrangement of generations http://www.oracle.com/ocom/groups/public/@otn/documents/digitalasset/190244.gif

You can set the ratio between Young Generation and Old (Tenured) Generation with the NewRatio parameter, and the ratio between Eden Space and Survivor Space with the SurvivorRatio parameter.

Recently this question was asked about finding out the default ratios for the heap spaces. It says you should use the PrintGCDetails parameter and calculate the ratios manually.

My question is: Does the size of the different heap spaces increase by the same ratio, thus keeping the ratio set between them at startup constant during the whole runtime of the application? For example, if Young Generation and Old/Tenured Generation has a default NewRatio of 3, and the initial reserved heap space is 100MB for Young, and 300MB for Old. If more memory needs to be reserved for the Old Space, lets say 300MB more making it 600MB total. Does memory reserved for Young Space also double to 200MB keeping the ratio intact?

解决方案

I think you are referring to GC Ergonomics and the Adaptive Size Policy

  • a feature of the Hotspost GC that automatically adapts the sizes of the generations at runtime based on the current allocation behavior of the running application.
  • This feature is ON by default and controls/adapts the size of the generations at runtime.
  • in fact, some of the GC parameters will be ignored if you do not disable Adaptive Size policy, eg. -XX:SurvivorRatio=.

You can disable the Adaptive Size Policy by using the -XX:-UseAdaptiveSizePolicy. Once you disabled the AdaptiveSizePolicy, the GC will respect the initial size of the generations as specified by your startup parameters (e.g. -Xms, -Xmx, -XX:MaxNewSize=,-XX:NewSize=, -XX:SurvivorRatio=) and they will remain constant.

You can find more on Adaptive Size policy in UseAdaptiveSizePolicy and other jvm opts.

这篇关于Java堆中的空间/世代之间的比率是不变的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆