- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Enable Verbose Garbage Collection
Welcome to this hands-on lab, where we will set Tomcat up to use verbose garbage collection. As part of this lab you will also enable parallel garbage collection. It is useful to have verbose garbage collection set, to help you troubleshoot your Tomcat instance and its applications. We are using Apache's Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The server provided in this lab environment is running Red Hat Enterprise 8 and has Tomcat 9 pre-installed for you. The Tomcat instance is available on port **8080**.

Lab Info
Table of Contents
-
Challenge
Test to Ensure You Can Access the Preconfigured Tomcat Instances on Port 8080
Use the Tomcat server's public IP address and port 8080. Connect to the Tomcat GUI and log in. The username and password to use are the same as what's provided for CLI access.
To access the server, copy the external IP address and test in your browser by using this IP address and appending the :8080 to it.
For example, if an IP address shown was 3.92.152.3, then you would put the following into your web browser:
http://3.92.152.3:8080
You should see the GUI.
Note: It may take from 3 to 10 mins after the Hands-On Lab has started before you can access the Tomcat servers on Port 8080.
-
Challenge
Configure Tomcat to Use Verbose and Parallel Garbage Collection
You will need to set options for Tomcat's startup routine so that it uses verbose and parallel garbage collection.
The options to add to the Tomcat startup file (you may need to create the file) are the following:
- Verbose garbage collection:
-verbose:gc
- Parallel Garbage collection:
-XX:-UseParallelGC
These entries should be exported as
CATALINA_OPTS
. - Verbose garbage collection:
-
Challenge
Restart Tomcat and Monitor the Logs for GC Messages
Restart the Tomcat server.
Check the Tomcat logs for entries relating to garbage collection. The log to look into is the
catalina.out
log.An example verbose log entry might look like the following:
[2.536s][info][gc] GC(0) Pause Young (Allocation Failure) 66M->7M(1015M) 22.821ms
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.