java JBOSS AS 5 的 JVM 6 内存设置如何?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1207140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How is your JVM 6 memory setting for JBOSS AS 5?
提问by Dani Cricco
I'm using an ICEFaces application that runs over JBOSS, my currently heapsize is set to
我正在使用在 JBOSS 上运行的 ICEFaces 应用程序,我当前的堆大小设置为
-Xms1024m –Xmx1024m -XX:MaxPermSize=256m
-Xms1024m –Xmx1024m -XX:MaxPermSize=256m
what is your recommendation to adjust memory parameters for JBOSS AS 5 (5.0.1 GA) JVM 6?
您对调整 JBOSS AS 5 (5.0.1 GA) JVM 6 的内存参数有何建议?
回答by Pascal Thivent
According to this article:
根据这篇文章:
AS 5 is known to be greedy when it comes to PermGen. When starting, it often throws
OutOfMemoryException: PermGen Error.
众所周知,当谈到PermGen时,AS 5 是贪婪的。启动时,经常抛出
OutOfMemoryException: PermGen Error.
This can be particularly annoying during development when you are hot deploying frequently an application. In this case, JBoss QA recommends to raise the permgen size, allow classes unloading and permgen sweep:
当您经常热部署应用程序时,这在开发过程中可能特别烦人。在这种情况下,JBoss QA 建议提高 permgen 大小,允许类卸载和 permgen 扫描:
-XX:PermSize=512m -XX:MaxPermSize=1024 -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
But this is more FYI, I'm not suggesting to apply this configuration blindly (as people wrote in comments, "if it ain't broken, don't fix it").
但这更多是仅供参考,我不建议盲目应用此配置(正如人们在评论中所写的那样,“如果它没有损坏,请不要修复它”)。
Regarding your heap size, always keep in mind: the bigger the heap, the longer the major GC. Now, when you say "it was definitely too small", I don't really know what this means (what errors, symptoms, etc). To my knowledge, a 1024m heap is actually pretty big for a webapp and should really be more than enough for most of them. Just beware of the major GC duration.
关于堆大小,请始终牢记:堆越大,主要 GC 的时间越长。现在,当你说“它肯定太小了”时,我真的不知道这意味着什么(什么错误、症状等)。据我所知,一个 1024m 的堆对于一个 webapp 来说实际上是相当大的,对于大多数人来说应该足够了。请注意主要的 GC 持续时间。
回答by Ondra ?i?ka
Heap: Start with 512 MB, set the cap to where you believe your app should never get, and not to make your server start swapping.
堆:从 512 MB 开始,将上限设置为您认为您的应用程序永远不会获得的位置,并且不要让您的服务器开始交换。
Permgen: That's usually stable enough, once the app reads all classes used in the app. If you have tested the app and it works with 256 MB, then leave it so.
Permgen:这通常足够稳定,一旦应用程序读取应用程序中使用的所有类。如果您已经测试了该应用程序并且它可以使用 256 MB,那么请保持原样。
回答by Joshua Davis
@wds: It's definitely not a good idea to set the heap maximum as high as possible for two reasons:
@wds:将堆最大值设置得尽可能高绝对不是一个好主意,原因有两个:
- Large heaps make full GC take longer. If you have PermGen scanning enabled, a large PermGen space will take longer to GC as well.
- JBoss AS on Linux can leave unused I/O handles open long enough to make Linux clean them up forcibly, blocking all processes on the machine until it is complete (might take over 1 minute!). If you forget to turn off the hot deploy scanner, this will happen much more frequently.
- 大堆使 full GC 需要更长的时间。如果您启用了 PermGen 扫描,那么大的 PermGen 空间也将花费更长的时间进行 GC。
- Linux 上的 JBoss AS 可以让未使用的 I/O 句柄打开足够长的时间,以使 Linux 强制清理它们,阻塞机器上的所有进程,直到它完成(可能需要 1 多分钟!)。如果您忘记关闭热部署扫描程序,这种情况会更频繁地发生。
This would happen maybe once a week in my application until I:
这可能会在我的申请中每周发生一次,直到我:
- decreased -Xms to a point where JBoss AS startup was beginning to slow down
- decreased -Xmx to a point where full GCs happened more frequently, so the Linux I/O handle clean up stopped
- 将 -Xms 降低到 JBoss AS 启动开始放缓的程度
- 将 -Xmx 降低到更频繁发生完整 GC 的程度,因此 Linux I/O 句柄清理停止
For developers I think it's fine to increase PermGen, but in production you probably want to use only what is necessary to avoid long GC pauses.
对于开发人员,我认为增加 PermGen 很好,但在生产中,您可能只想使用避免长时间 GC 暂停所需的内容。

