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?

4 Answers 4


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

  • Beware also of the Virtual memory that the JVM only reserves, and doesn't use yet. May 26, 2009 at 11:46
  • True, most of these segments, like the PermGen and the Code Cache are allocated on startup, but most kernels will avoid allocating pages to those segments until needed. May 26, 2009 at 11:47
  • 1
    Thanks for the info - I think this explains where the memory is going. Is there any way to change these values? Even better would be a way to see how much of each section was in use - I don't know if any of the Java debugging/monitoring tools let you do this?
    – Draemon
    May 31, 2009 at 0:47
  • 1
    You can use pmap, or jmap to get an idea about the various segments in use. Most of the common options (and their defaults) are listed here, java.sun.com/javase/technologies/hotspot/vmoptions.jsp. They change often and are subject to differences in OS (stack size usually) and arch (64bit OS's generally imply larger JVM areas) May 31, 2009 at 3:43

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.

  • VisualVM can also be used instead of JConsole and give even more details when looking for memory problems within the JVM. I've had to use this on more than one occasion to find problems. Jul 19, 2009 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.