什么时候不使用G1GC垃圾收集器?
我研究了可用于JVM的各种垃圾收集器之间的差异。 是解释它们之间主要区别的答案: https://stackoverflow.com/a/54619838/54619838/5345646
这 为G1GC说:
它是低暂停 /服务器样式GC,主要用于大堆(&gt; 4GB)。< / p>
我们有一台机器的总内存为4 GB,并且分配给JVM的堆尺寸为1 GB。我想了解这是否会给我们带来任何问题,还是G1GC可以奏效。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下摘要基于:
如果您对GC停顿时间绝对没有兴趣,请使用串行收集器(如果您只有一个核心)或并行收集器(如果您有一个以上的核心)。
如果您需要低暂停时间(概率很高),则使用G1收集器。
如果您需要超低的停顿时间,并且/或者您的堆非常大,请使用z收集器。
从Java 14开始,旧的CMS收集器已被删除。
请注意,如果您指定暂停时间和/或吞吐量目标,则可以将GC的选择和调整放在JVM上。当您不了解自己在做什么时,这可能比手动选择和调整GC的风险要小。
描述了这种“基于行为的调谐”方法及其优势在这里。
您问:
我们无法告诉您是否可以正常工作。这将取决于应用程序行为的各个方面以及您的期望。例如,如果您的应用程序遇到了这些问题,那么“问题”会涉及您。我建议尝试“基于行为的调谐”,然后看看那些带您的地方。
最后,设置最大的堆大小太小,无法用于应用程序,无论您选择什么GC,都不会结束 ...。
The following summary is based on:
If you have absolutely no interest in GC pause times, then use the serial collector (if you only have one core) or the parallel collector (if you have more than one core).
If you need low pause times (with high probability), then use the G1 collector.
If you need ultra-low pause times, and/or you have an extremely large heap, use the Z collector.
The old CMS collector has been removed as of Java 14.
Note that if you specify pause-time and/or throughput goals, you can leave the choice and tuning of the GC to the JVM. This is probably less risky than manually selecting and tuning the GC ... when you don't understand what you are doing.
This "behavior-based tuning" approach and its advantages are described here.
You asked:
We can't tell you whether it would work out fine or not. It would depend on various aspects of your application's behavior and also on your expectations. For example, what "issues" would concern you if your application encountered them. I would recommend trying "behavior-based tuning" to start with, and see where that gets you.
Finally, setting a maximum heap size that is too small for the application will not end well ... no matter what GC you select.