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?
In addition to the heap (specified by
-Xms
and-Xmx
) you need to include the non heap areas. These includeDirectByteBuffer
s are drawn from), this is initially 64mbThere 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.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".
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.
One useful technique I've found is to use JMX monitoring to see exactly how much memory is used by the heap vs permgen space.
Set up JMX in Tomcat as described here http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html
Then use JConsole (comes with JDK 5 or JDK 6) -- the memory tag will track memory consumption over time.
Also -- beware of soft restarts of webapps. If you reload a webapp, the permgen space will not be garbage collected and will build up over time. You need to do a full stop/start of Tomcat in order to reclaim the permgen space.