是否有针对 GC 问题的食谱指南?

2022-01-16 00:00:00 garbage-collection java

几乎每个人最终都会遇到 Java 的 GC 问题.

是否有针对 Java 调整 GC 的食谱指南或半自动化工具?

我的理由是:

  • 几乎所有人最终都会遇到这些问题
  • 有许多可能的因素(比如 20 个),其中只有少数会影响您的问题.
  • 大多数人不知道如何识别关键因素,因此 GC 调优更像是一门魔法而不是一门科学.
  • 并非所有人都使用 HotSpot 虚拟机.不同的 Sun 版本具有不同的 GC 特性.
  • 几乎没有进行实验的动力(例如每天使用略有不同的设置运行虚拟机,看看效果如何).

所以问题真的是:有什么东西可以以清单的方式使用吗?或者甚至可能是一个分析 GC 日志或堆转储并向我提供具体提示的工具(而不是告诉我95% 的数据分配在 byte[] 类型的对象中",这基本上是无用的).

相关问题:

  • 适当的 Tomcat 5.5 启动参数来调整 JVM 以适应极高需求的大型堆 Web 应用程序? 这是非常具体的.我的问题范围更广.
  • 什么是客户端的最佳垃圾收集设置一边? 范围又很窄
  • 有谁知道在 Java 中配置 GC 的好指南? 仅限 HotSpot
  • JVM 内存管理 &垃圾收集书? 那里有 80%,但我缺少清单/食谱/傻瓜方法.

解决方案

各种GC信息的参考:

甲骨文

使用 5.0 Java[tm] Virtual 调整垃圾收集机器

还有这个

Java SE 6 HotSpot[tm] 虚拟机垃圾回收调优

IBM

微调垃圾收集 [链接失效]

可扩展的详细工具包

SAP JVM

内存管理(垃圾回收)

检测内存泄漏

检测挂起/循环的虚拟机p>

分析内存不足情况

抱歉,我对 SAP 了解不多,但提供了一些我发现的东西.

就食谱而言,调优很可能是这个级别的特定应用程序,但它是一个有趣的话题.

附录

您还提到了分析工具.此处列出了一些候选人:

知道任何 Java 垃圾收集日志分析工具吗?

Almost everyone eventually runs into GC issues with Java.

Is there a cookbook guide or semi-automated tool to tune GC for Java?

My rationale is this:

  • Almost anyone eventually has these problems
  • There are many possible factors (say 20) out of which only a few affect your problem.
  • Most people don't know how to identify the key factors so GC tuning is more like a black art than a science.
  • Not everyone uses a HotSpot VM. Different Sun versions have different GC characteristics.
  • There is little incentive to experiment (like run the VM with slightly different settings every day to see how they play out).

So the question really is: Is there something that I can use in a check-list manner? Or maybe even a tool that analyzes GC logs or heap dumps and gives me specific hints where to look (instead of telling me "95% of the data is allocated in objects of the type byte[]" which is basically useless).

Related questions:

  • Appropriate Tomcat 5.5 start-up parameters to tune JVM for extremely high demand, large heap web application? which is very specific. My question is more wide.
  • What are the best garbage collection settings for client side? Again very narrow scope
  • Does anyone know of a good guide to configure GC in Java? HotSpot only
  • JVM memory management & garbage collection book? is 80% there but I'm missing the checklist/cookbook/for-dummies approach.

解决方案

References for various GC information:

Oracle

Tuning Garbage Collection with the 5.0 Java[tm] Virtual Machine

and this also

Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning

IBM

Fine Tuning Garbage Collection [link dead]

Extensible Verbose Toolkit

SAP JVM

Memory Management (Garbage Collection)

Detecting Memory Leaks

Detecting Hanging / Looping VMs

Analyzing Out-of-Memory Situations

Sorry I don't know much about SAP but have provided some things I have found.

As for a cookbook, tuning is most likely application specific at this level, but it is an interesting topic.

ADDENDUM

You also mentioned analysis tools. Some candidates are listed here:

Know of any Java garbage collection log analysis tools?

相关文章