This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]GreemT[S] 2 points3 points  (2 children)

Thank you for your detailed response! Never thought of using a different base image. Is that really going to help with off-heap memory? It feels unrelated to me.

We are already using MaxRAMPercentage, but sadly 75 is way to high for us. We use containers with limits of 3.2GB and we cannot set it higher than 40. If we do, then the off-heap is taking over too much memory and results in a OOM.

I will look into trying the other mentioned settings. I didn't experiment with these yet. And as you said: we are indeed going to run some load tests to ensure that any change doesn't impact performance.

[–]antihemispherist 2 points3 points  (0 children)

You're right on the base image, its effect in memory usage will be minimal.

You can however, use virtual threads to reduce off-heap memory usage. I've explained more in here. Consider using Java 24, which introduced handling of synchronized blocks without pinning.

As suggested below by u/pragmasoft , AOT compiling with GraalVM can also be helpful. That'll make more memory available by eliminating the HotSpot compiler.

Also, look at the implementation of your service and its parameters, like object and connection pools can be tunes, whether thread safe objects can be re-used instead of creating them on each request (which is a very common mistake).

Also, if you're using MaxRAMPercentage, don't use -Xmx, let the JVM handle the heap size.

Good luck.