简体   繁体   English

JVM 性能调优:young copy vs old generation gc

[英]JVM performance tuning: young copy vs old generation gc

Hi: I have a multi thread Java application.嗨:我有一个多线程 Java 应用程序。 There are many temporary objects.有很多临时对象。
-XX:MaxTenuringThreshold=1 , we put above parameter when starting JVM. -XX:MaxTenuringThreshold=1 ,我们在启动 JVM 时输入上述参数。 This means all the objects would be survive once during gc, then it would be promoted to old generation.这意味着所有对象将在 gc 期间存活一次,然后将其提升到老年代。 Could we put this -XX:MaxTenuringThreshold=10 for example, so that object would be promoted to old JVM old generation after 10 times gc.我们可以把这个-XX:MaxTenuringThreshold=10例如,这样在 10 次 gc 后 object 将被提升为旧的 JVM 老一代。 But will that cause unnecessary copy operation during young gc (since objects are copied 'from 'eden' to 'from', from 'from' to 'to', 'from','to' are two survivor buffer)?但这会在年轻 gc 期间导致不必要的复制操作(因为对象从 'eden' 复制到 'from'、从 'from' 复制到 'to'、'from'、'to' 是两个幸存者缓冲区)?

The questions might also mean if a) there are multiple times copy in young generation,less old generation gc, b) long old generation garbage collection but few young generation copy, which one is better for good performance?这些问题也可能意味着如果a)年轻代中有多次复制,老年代gc较少,b)老年代垃圾收集时间长但年轻代复制很少,哪一个更好?

Which one is "better for good performance" depends very much on your application and the conditions under which it operates.哪一个是“更好的性能”很大程度上取决于您的应用程序及其运行条件。 Your best hope is to try various garbage collection options and then do runtime and memory profiling to get the best trade-off between memory usage and speed.您最好的希望是尝试各种垃圾收集选项,然后进行运行时和 memory 分析,以在 memory 使用和速度之间取得最佳平衡。

There is, sadly, no silver bullet for garbage collection settings.遗憾的是,垃圾收集设置没有灵丹妙药。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM