I'm not interested for a specific application or environment. Although I'm facing this problem with my application deployment now, I'm interested in a more general solution.
Are there some rules on how big to set the heap size on a java server? (Especially now, I'm working with Tomcat 7). With -Xms
and -Xmx
you can specify the minimum respectively maximum values for heap size. Based on the applications that are deployed on server, how to know what maximum and minimum heap size to set. Is there a generic way to find it, or is it more empirical, related to the deployed application(s) ? - by 'related to the deployed appliccation(s)' I mean that you must know what your application is doing, database work, user interface work, or any other memory consumer things.
This is empirical - observe your application and see how it behaves.
And there is more to it - for a starter, read about memory pools and how to size them. If you get into it, look at http://www.javaperformancetuning.com/ - there's a lot of materials about tuning memory issues, and more.
Now, in the usual case, you should not bother with -Xms
. Set -Xmx
to whatever value your application needs (observe, to find out). JVM increases the size of memory pools when it needs to, and decreases them accordingly. Just make sure, you don't get OutOfMemoryError
s. And then, look into your application for memory bottlenecks (like, for example full GC's, or long stop-the-world phase), and size the pools and/or configure the GC if you need to.