Spring Boot application container memory footprint (Java 21)

26 Views Asked by At

Let me preface this by saying I know it is hard to find a solution to my problem here. This is more to know what other people's experiences have been with Spring Boot, containers and Java 21.

So the problem is high memory consumption. This is your standard Spring Boot application, with a handful of REST APIs and two SQS consumers. I am deploying it to a server with -Xmx512m and I set the container memory limit to 682MB (25% room for non-heap/OS). After some time the java process reaches the 682MB mark and is killed by the docker management daemon. It doesn't matter if it is doing work or not; it slowly increases RSS memory even when idle. Yesterday I changed the container resources to not have a limit but rather a reserve of 1G, while keeping the -Xmx512m VM option. This application is now comfortably sitting at 1397MB of memory.

Have anyone had similar experiences with Spring Boot applications? By the way the behavior is the same whether I use Java 17 or 21. I have used Spring Bot 3.1.1/3.2.3 respectively. I don't think this is a memory leak, but how do I go about troubleshooting something like this? Is profiling my only option?

0

There are 0 best solutions below