JVM Memory Consumption
I am trying to run tomcat on a low memory system (150-256Mb). Even though I start the JVM with -Xmx64m (which should be the default anyway), the process immediately takes up 200Mb+.
I wonder why the JVM needs so much memory itself, or if there is a way of tuning this? Are other JVMs better than the sun one for low memory consumption - and do they work with tomcat?
Solution 1:
In addition to the heap (specified by -Xms
and -Xmx
) you need to include the non heap areas. These include
- The Perm Gen, which is 64mb on 32bit systems, and 96mb on 64bit systems initially
- The Code Cache, which is between 20 and 40mb depending on JVM
- The NIO buffer area (where
DirectByteBuffer
s are drawn from), this is initially 64mb
There is also the working space of the JVM itself which will be a few dozen mb.
You should also be aware of the Sun JVM's auto sizing when using a server class machine. Over time the definition of server class (2Gb memory, more than one core) has suffered some depreciation and now most machines are capable of triggering the -server
optimizations. My advice is always to specify the -Xms
and -Xmx
settings and pass -server
unless you can think of a good reason not too.
Solution 2:
With the -Xmx option you restrict the size of the heap that the JVM reserves... There are additional resources the JVM needs...
"Thanks for the memory"* is a good article that explains how a JVM uses memory...
Apart from that u could try IBM's JVM it should work with Tomcat, don't know if some of the free JVM implementations work.
Nevertheless, I don't think that a machine with memory that low, will do u any good. Java just needs memory.
*As new users can't submit hyperlinks, you have to look up that article yourself... it's the first hit on google for "thanks for the memory ibm".
Solution 3:
Also try the JRockit JVM, which has less memory footprint. You can still download BEA licensed JRockit versions for free. i.e. versions before Oracle took over BEA.
See http://forums.oracle.com/forums/thread.jspa?threadID=816133&tstart=0 for download links.