在什么情况下Java性能会随着内存的增加而降低? [英] Under what circumstances does Java performance degrade with more memory?

查看:136
本文介绍了在什么情况下Java性能会随着内存的增加而降低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在DEV环境中加载测试Java 1.6应用程序。 JVM堆分配为2Gb,-Xms2048m -Xmx2048m。在负载测试下,应用程序运行平稳,从不使用超过1.25Gb的堆,垃圾收集完全正常。

We're load testing a Java 1.6 application in our DEV environment. The JVM heap allocation is 2Gb, -Xms2048m -Xmx2048m. Under load testing, the app runs smooth, never uses more than 1.25Gb of heap, and garbage collection is totally normal.

在我们的UAT环境中,我们运行负载测试使用相同的参数,唯一的区别是JVM,它分配了4Gb,-Xms4096m -Xmx4096m,否则,硬件与DEV完全相同。但是在负载测试期间,性能非常糟糕,应用程序几乎吞噬了整个堆,并且垃圾收集泛滥。

In our UAT environment, we run the load test with the same parameters, the only difference is the JVM, it's allocated 4Gb, -Xms4096m -Xmx4096m, otherwise, the hardware is exactly the same with DEV. But during load testing, the performance is horrendous, the app eats up nearly the entire heap, and garbage collection runs rampant.

我们一遍又一遍地运行这些测试,消除了可能影响性能的所有可能症状,但结果是一样的。在什么情况下会是这种情况?

We've run these tests over and over again, eliminated all possible symptoms that may influence performance, but the results are the same. Under what circumstances can this be the case?

推荐答案

罪魁祸首可能是垃圾收集,正常的停止世界 - 类型集合给我们带来了一些性能问题服务器软件运行速度很慢,但服务器的负载也很低。最终我们发现有一个停止世界 - 垃圾收集器线程阻止在某些情况下运行的整个软件(产生大量垃圾的操作)。

The culprit could be garbage collection, normal "stop-the-world"-type collection caused us some performance problems; the server-software was running very slow, yet the load of the server was also low. Eventually we found out that there was a single "stop-the-world" -garbage collector thread holding up the entire software being run all the time under certain scenarios (operations producing loads of garbage).

迁移到并发垃圾回收缓解了启动参数的问题 -XX:+ UseParallelOldGC -XX:ParallelGCThreads = 8 。我们在测试和生产中使用仅2gb堆,但同样值得注意的是GC占用的时间越长堆(即使您的软件实际上从未使用过全部堆)。

Moving to concurrent garbage collection alleviated the problem with start up parameters -XX:+UseParallelOldGC -XX:ParallelGCThreads=8. We were using "only" 2gb heaps in tests and production, but it is also worthy of noting that the amount of time the GC takes goes up with larger heap (even if your software never actually uses all of it).

您可能想要阅读更多有关不同垃圾收集器的信息并从此处进行调整: Java SE 6 HotSpot [tm]虚拟机垃圾收集调整

You might want to read more about different garbage collector -options and tuning from here: Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning.

此外,这个问题的答案可以提供一些帮助: Java非常大的堆大小

Also, answers in this question could provide some help: Java very large heap sizes.

这篇关于在什么情况下Java性能会随着内存的增加而降低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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