# Tomcat process memory higher than the JVM heap memory

**URL:** <https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433>\
**Category:** Open Q&A\
**Tags:** memory, tomcat, java\
**Created:** [May 3, 2024, 8:18pm UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433 "2024-05-03T20:18:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveench](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@naveench](https://community.dynatrace.com/u/naveench)\
**Post date:** [May 3, 2024, 8:18pm UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/1 "2024-05-03T20:18:42Z")

</div>

We are running a SpringBoot application in tomcat 9.x with OpenJDK11. This application is hosted on a VM.

We have been observing high memory utilization of the tomcat process in dynatrace. “Memory Usage” graph of the process is showing 5.3gb while the heap memory usage is 2 gb. Can someone help me where the remaining 3.3gb memory is used?

Note: tomcat profile contains only one application running in it. We are using&nbsp;Xms as 1024m and Xmx as 4096.

 ![heap-memory.jpg](https://global.discourse-cdn.com/dynatrace/original/2X/2/292799de7a1358cac8cfe597e158dbb46e976a0a.jpeg)

 ![process-memory.jpg](https://global.discourse-cdn.com/dynatrace/original/2X/5/52eccf96afc6d144966679402f111d18362d48bf.jpeg)

---

<div class="post-metadata">

**Author:** ![richard\_guerra](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/richard_guerra/32/9592_2.png) [@richard\_guerra](https://community.dynatrace.com/u/richard_guerra)\
**Post date:** [May 4, 2024, 4:43am UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/2 "2024-05-04T04:43:26Z")

</div>

Observation - in your heap memory chart, I don’t see any garbage collection activity.

Guess - some stuck thread that cascades in the application to build up threads/stack-memory-consumption - with a overall process “hang” at 10:30.

You need a thread dump or heap dump to analyze what is in there that may be the culprit.

If this is hard to do in retrospect, is there a possibility to load-test the app in a lower environment (PTE), and analyze threads and heap objects there?

Here are two good discussions of the differences in heap memory vs process memory -

[https://stackoverflow.com/questions/8037920/tomcat-memory-consumption-is-more-than-heap-permgen-space](https://stackoverflow.com/questions/8037920/tomcat-memory-consumption-is-more-than-heap-permgen-space)

> **[Java Heap Space vs Stack Memory: Complete Guide | DigitalOcean](https://www.digitalocean.com/community/tutorials/java-heap-space-vs-stack-memory)**
>
> Understand Java heap space and stack memory differences. Learn memory allocation, garbage collection, performance, and common OutOfMemoryError solutions.

---

<div class="post-metadata">

**Author:** ![PierreGutierrez](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pierregutierrez/32/5934_2.png) [@PierreGutierrez](https://community.dynatrace.com/u/PierreGutierrez)\
**Post date:** [May 5, 2024, 9:00pm UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/3 "2024-05-05T21:00:44Z")

</div>

Hi&nbsp;[@naveench](https://community.dynatrace.com/user/75388)&nbsp;  
I agree with what was mentioned by&nbsp;[@richard\_guerra](https://community.dynatrace.com/user/39338)

In the link shared by Richard, the case is similar to the one mentioned.  
And it is based on the concept that “Memory usage” is not only Heap Memory, but there are also many more factors:

 ![PierreGutierrez_0-1714942470456.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/4/740c0deeb3a369db32e4e723ef64038c24dabece.png)

I also mention that seeing that your process is using 5.3 GB of which you assign a maximum of 4 GB for only heap Memory, makes me think that you can optimize that parameter.&nbsp; I found some important information about it here:&nbsp;  
[Java Experto: rendimiento (upc.edu)](http://seminarisempresa.fib.upc.edu/aulesempresa/2011/programes/Bitendian/Llista-documents/0/document/metodologies-tuning.pdf)&nbsp; &nbsp;,&nbsp;[Memory Management](https://docs.oracle.com/en/graalvm/jdk/21/docs/reference-manual/native-image/optimizations-and-performance/MemoryManagement/)&nbsp;.

The best way is to apply parameters and apply load tests on your service, to arrive at the parameters that are useful to you.

I hope it’s helpful 💪

---

<div class="post-metadata">

**Author:** ![erh\_inetum](https://avatars.discourse-cdn.com/v4/letter/e/48db29/32.png) [@erh\_inetum](https://community.dynatrace.com/u/erh_inetum)\
**Post date:** [May 6, 2024, 4:38am UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/4 "2024-05-06T04:38:32Z")

</div>

Hi&nbsp;[@naveench](https://community.dynatrace.com/user/75388)&nbsp;,

Completing Richard and Pierre comments, a best practice is configuring the same value for -Xms and -Xmx parameters. And these values shouldn’t exceed 4096M. JVMs don´t usually handle propertly values greater than 4GB.  
You can also add to the JVM configuration parameters the GC algorithm (G1, Epsilon or Serial) to managed heap. This usually works fine.

Hope it helps.  
Regards,  
Elena.

---

<div class="post-metadata">

**Author:** ![naveench](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@naveench](https://community.dynatrace.com/u/naveench)\
**Post date:** [May 6, 2024, 8:09pm UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/5 "2024-05-06T20:09:48Z")

</div>

Thanks&nbsp;[@richard\_guerra](https://community.dynatrace.com/user/39338)&nbsp;, thats good observation. We will get the heap and thread dumps and will review them.

---

<div class="post-metadata">

**Author:** ![naveench](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@naveench](https://community.dynatrace.com/u/naveench)\
**Post date:** [May 6, 2024, 8:51pm UTC](https://community.dynatrace.com/t/tomcat-process-memory-higher-than-the-jvm-heap-memory/45433/6 "2024-05-06T20:51:12Z")

</div>

thanks for your suggestions&nbsp;[@erh\_inetum](https://community.dynatrace.com/user/40722)&nbsp; we will update the configuration parameters.
