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

Set Fixed Heap Size in Tomcat
Welcome to this hands-on lab, where we will set Tomcat to use a fixed heap size. This is so that the memory is pre allocated. 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 for you on port **8080**, on the provided server. Once the heap size is set, you should be able to see the changes on the Tomcat Manager GUI page.

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 to 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 paste it in your browser, then append :8080 to it.
For example, if the 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 server's GUI on port 8080.
-
Challenge
Go to the Tomcat GUI and Check the JVM Memory Settings
Go to the Tomcat GUI and check the server status page. You should take note of the memory settings that are originally applied to the Tomcat instance.
-
Challenge
Change Your Tomcat Server so It Has a Minimum and Maximum Heap Size of 1gb
The options to add to the Tomcat startup file (you may need to create the file) are these:
-Xms1g
-Xmx1g
This should be set in a file under the
bin
folder calledsetenv.sh
.These entries should be exported as
CATALINA_OPTS
. -
Challenge
Restart the Tomcat Server and Check the JVM Memory
Go to the Tomcat Manager GUI, then to the Server Status application and check the JVM memory.
It should reflect the changes you made to the minimum and maximum settings, and be much higher than the original settings.
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.