Hello Community

We're experiencing a significant memory leak issue with our production
Tomcat setup and would appreciate guidance on best practices and potential
fixes.
Environment Details

   -

   Tomcat Version: Apache Tomcat 7.0.41
   -

   Heap Size: 6GB (max)
   -

   Number of WAR files: 7
   -

   Application Type: Java & Spring Boot
   -

   Deployment Mode: hot-updates using symlinked WAR files
   -

   OS: Linux
   -

   JVM: OpenJDK 8 (1.8.0_412)

Current Deployment Approach

We're using a symlink-based deployment strategy:

   1.

   Actual Tomcat webapps path: */path/to/tomcat/webapps/*
   2.

   Git repository containing WAR files: */path/to/repo/warFiles/*
   3.

   Symlinks created from Git repo to Tomcat webapps directory
   4.

   Deployment process: *git pull* to update WAR files, no Tomcat restart
   5.

   *server.xml* configuration:

<Host name="localhost" appBase="webapps"
      unpackWARs="true" autoDeploy="true">
Problem Description

Over the past 5 months (since the last Tomcat restart), we've observed a
progressive memory leak with the following pattern:

Class Count Growth (Staircase Pattern):

   -

   Initial: 50k-56k classes
   -

   After each git pull/deployment: Incremental increase
   -

   Peak: 250k classes
   -

   After restart: Back to 50k-55k classes

Performance Degradation:

Metric

Before Restart

After Restart

Class Count

250k

55k

Max GC Count

56

46

Avg GC Count

10

6

Max GC Time

2000ms

963ms

Avg GC Time

400ms

215ms

Avg JVM Threads

1.44k

277
Monitoring

We've been monitoring this issue through Zabbix, and the graphs clearly
show the progressive degradation over time (includes incident &
after-incident pattern as well):

   -

   Class count growth over the months (showing staircase pattern from 50k
   to 250k)
   [image: Screenshot from 2025-11-24 18-58-46.png]
   -

   GC activity trends (count and time)
   [image: Screenshot from 2025-11-24 19-08-21.png]

   -

   Memory/Heap usage over time
   [image: Screenshot from 2025-11-24 19-13-01.png]


   -

   Thread count growth
   [image: Screenshot from 2025-11-24 19-13-52.png]

Incident: After a recent git pull, Tomcat experienced an OutOfMemoryError,
generated heap dump files, and crashed. The system was unresponsive until
we performed a restart.
Questions for the Community

   1.

   Is our symlink-based deployment approach with autoDeploy="true" causing
   classloader leaks??

   2.

   What is the recommended deployment strategy for production environments
   to avoid memory leaks when updating WAR files??

   3.

   Are there known issues with Tomcat 7.0.41 related to classloader leaks
   during redeployment??

   4.

   What monitoring or preventive measures can we implement to detect and
   mitigate this issue before it causes production outages??

We suspect the combination of symlinked WAR files, autoDeploy="true", and
no-restart deployments is preventing proper cleanup of old classloaders,
but we'd like to understand the root cause and implement a robust solution.

Any insights, best practices, or references to similar issues would be
greatly appreciated.

Thank you for your time and assistance.


Thanks & Regards

Harshit Sharma

Reply via email to