Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat memory leaks

I found this is a well known problem on Tomcat, so I'm trying to solve it on my server.

Deploying/undeploying war files on my Tomcat I often get this alert checking memory leaks:

The following web applications were stopped (reloaded, undeployed), but their
classes from previous runs are still loaded in memory, thus causing a memory
leak (use a profiler to confirm):
/GEKKO
/GEKKO
/GEKKO
/LinkPlatform

This answer https://stackoverflow.com/a/4565522/1061499 suggests to:

Make sure your web application does not use any java classes that are in the web container shared libraries. If you have any shared libraries, make sure there is no strong references to the objects in those libraries

What does it mean? I'm using Maven in my Eclipse project and all dependencies are automatically loaded. But I have to manually add Tomcat libraries in project build path (Server Runtime). Is this the problem? Are Tomcat jars "shared libraries"?

like image 634
davioooh Avatar asked Jun 29 '26 14:06

davioooh


1 Answers

Jars that are provided by Tomcat at runtime should be scoped as provided if you need them to compile but expect the Tomcat container to provide them at runtime, e.g.

  <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>
  </dependency>

(version is just something I threw in there... use whatever is appropriate).

like image 127
spudone Avatar answered Jul 02 '26 03:07

spudone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!