Chuck and Brian,
On 2/15/24 10:53, Chuck Caldarale wrote:
On Feb 15, 2024, at 09:04, Brian Braun <java08275...@gmail.com> wrote:
I discovered the JCMD command to perform the native memory tracking. When
running it, after 3-4 days since I started Tomcat, I found out that the
compiler was using hundreds of MB and that is exactly why the Tomcat
process starts abusing the memory! This is what I saw when executing "sudo jcmd
<TomcatProcessID> VM.native_memory scale=MB":
Compiler (reserved=3D340MB, commited=3D340MB)
(arena=3D340MB #10)
Then I discovered the Jemalloc tool (http://jemalloc.net
<http://jemalloc.net/>) and its jeprof
tool, so I started launching Tomcat using it. Then, after 3-4 days after
Tomcat starts I was able to create some GIF images from the dumps that
Jemalloc creates. The GIF files show the problem: 75-90% of the memory is
being used by some weird activity in the compiler! It seems that something
called "The C2 compile/JIT compiler" starts doing something after 3-4 days,
and that creates the leak. Why after 3-4 days and not sooner? I don't know.
There have been numerous bugs filed with OpenJDK for C2 memory leaks over the
past few years, mostly related to recompiling certain methods. The C2 compiler
kicks in when fully optimizing methods, and it may recompile methods after
internal instrumentation shows that additional performance can be obtained by
doing so.
I am attaching the GIF in this email.
Attachments are stripped on this mailing list.
:(
I'd love to see these.
Does anybody know how to deal with this?
You could disable the C2 compiler temporarily, and just let C1 handle your
code. Performance will be somewhat degraded, but may well still be acceptable.
Add the following to the JVM options when you launch Tomcat:
-XX:TieredStopAtLevel=1
By the way, I'm running my website using Tomcat 9.0.58, Java
"11.0.21+9-post-Ubuntu-0ubuntu122.04", Ubuntu 22.04.03. And I am developing
using Eclipse and compiling my WAR file with a "Compiler compliance
level:11".
You could try a more recent JVM version; JDK 11 was first released over 5 years
ago, although it is still being maintained.
There is an 11.0.22 -- just a patch-release away from what you appear to
have. I'm not sure if it's offered through your package-manager, but you
could give it a try directly from e.g. Eclipse Adoptium / Temurin.
Honestly, if your code runs on Java 11, it's very likely that it will
run just fine on Java 17 or Java 21. Debian has packages for Java 17 for
sure, so I suspect Ubuntu will have them available as well.
Debian-based distros will allow you to install and run multiple
JDKs/JREs in parallel, so you can install Java 17 (or 21) without
cutting-off access to Java 11 if you still want it.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org