JVM 性能调优:年轻副本与老年代GC
你好:我有一个多线程 Java 应用程序。有很多临时对象。-XX:MaxTenuringThreshold=1
,我们在启动JVM时输入上面的参数。这意味着所有对象在GC期间都会存活一次,然后就会被提升到老年代。我们能否以这个-XX:MaxTenuringThreshold=10
为例,这样该对象在经过10次gc后就会被提升到旧的JVM老年代。但这会在年轻GC期间导致不必要的复制操作吗(因为对象被复制“从'eden'到'from',从'from'到'to','from','to'是两个幸存者缓冲区)?
这些问题也可能意味着如果a)年轻代中有多次复制,老年代GC较少,b)老年代垃圾收集时间长但年轻代复制很少,哪一个对于良好的性能更好?
Hi: I have a multi thread Java application. There are many temporary objects.-XX:MaxTenuringThreshold=1
, we put above parameter when starting JVM. This means all the objects would be survive once during gc, then it would be promoted to old generation. Could we put this -XX:MaxTenuringThreshold=10
for example, so that object would be promoted to old JVM old generation after 10 times gc. 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)?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哪一种“性能更好”很大程度上取决于您的应用程序及其运行条件。您最好的希望是尝试各种垃圾收集选项,然后进行运行时和内存分析,以获得内存使用和速度之间的最佳权衡。
遗憾的是,垃圾收集设置没有灵丹妙药。
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.
There is, sadly, no silver bullet for garbage collection settings.