O'Reilly logo

Tomcat: The Definitive Guide, 2nd Edition by Ian F. Darwin, Jason Brittain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java VM Configuration

How Tomcat will run depends in part on how you configure the Java virtual machine in which it runs. For example, if you do not configure the JVM to be able to use up to a specified amount of heap memory, it will use only up to the default amount of memory, which may not be enough for the web application you're trying to run. If Tomcat does not have sufficient memory to run your webapp on startup, it will just serve error pages to all web clients. If Tomcat has enough memory to start your webapp but not enough to process as many concurrent requests as you configured your connector to allow into Tomcat, some or all of the requests will get an error response or a dropped connection.

There is a plethora of JVM startup switch settings that you may set. See Table 2-1 for the settings we chose as some of the most useful JVM startup switch settings you can use when running Tomcat.

Table 2-1. Java VM configuration options

Use

JVM option

Meaning

[a]
[b]

Memory setting

-Xms384M

Sets the heap memory size at JVM startup time.

Memory setting

-Xmx384M

Sets the maximum heap memory size the JVM can expand to.

Debugging security

-Djava.security.debug=all

Turns on all debug output for security.[a]

Debugging

-enableassertions

Enables assertion checking.[b]

Debugging

-verbose:class

Enables verbose class loading debug output.

Debugging

-verbose:gc

Enables verbose garbage collection debug output.

Graphical

-Djava.awt.headless=true

Allows the JVM to run without ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required