views:

1674

answers:

4

I'm using an ICEFaces application that runs over JBOSS, my currently heapsize is set to

-Xms1024m –Xmx1024m -XX:MaxPermSize=256m

what is your recommendation to adjust memory parameters for JBOSS AS 5 (5.0.1 GA) JVM 6?

A: 

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.

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.

Ondra Žižka
+1  A: 

According to this article:

AS 5 is known to be greedy when it comes to PermGen. When starting, it often throws 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:

-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.

Pascal Thivent
Great suggestions! JBoss 5 and 6M3 don't like "+CMSPermGenSweepingEnabled" though. They say to use -XX:+CMSClassUnloadingEnabled instead.
Jon
A: 

Your PermGen size can be the default as long as that doesn't cause any problems. If apps start crashing due to PermGen running out you're either being hit by the all too common problems with memory leaks when redeploying, or you're just deploying a lot of stuff with a lot of different libraries. The latter can be fixed by increasing the available space, the former must be fixed on an application by application basis.

Now for the other settings, the answer is very simple: set -Xms to something sensible (i.e. 1024MB) and -Xmx as high as you can. As high as you can in this case meaning "whatever physical memory is still available under typical load with all other applications running". Subtract a couple 100 megs to make room and use that number.

If you're running your server in a development/test environment you might want to set your heap size a bit lower to be able to more easily catch memory leaks.

edit: BTW, this seems more like a question for serverfault?

wds
I really do **not** agree with "`-Xmx` as high as you can".
Pascal Thivent
A: 

@wds: It's definitely not a good idea to set the heap maximum as high as possible for two reasons:

  1. Large heaps make full GC take longer. If you have PermGen scanning enabled, a large PermGen space will take longer to GC as well.
  2. 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.

This would happen maybe once a week in my application until I:

  1. decreased -Xms to a point where JBoss AS startup was beginning to slow down
  2. decreased -Xmx to a point where full GCs happened more frequently, so the Linux I/O handle clean up stopped

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.

Joshua Davis