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

Get Tomcat: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.