0

I'm running a JVM inside a docker container. I set memory limit for container with a hardcoded value. And I use new -XX:UseCGroupMemoryLimitForHeap option for JVM. In this case JVM should allocate heap memory depending on the container memory.

JVM actually does it, up to some point. If you give 500Mb of container memory JVM allocates 444.5 MB memory as expected.

But then JVM gets stuck at 1.74 Gb of heap memory. Even given 8Gb of container memory, JVM still allocates 1.74 Gb heap memory.

I can allocate 4Gb of heap memory with -Xmx option.

How can I let JVM allocate as much memory as it can?

3
  • Can you post all the jvm flags that you're using? Commented Jan 4, 2018 at 19:00
  • -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 but i fixed the problem. There was no problem actually. These flags work as expected and JVM allocates as much memory as possible. Problem was my docker memory limit. Commented Jan 5, 2018 at 7:38
  • 2
    Possible duplicate of How do I start a JVM with unlimited memory? Commented Jan 6, 2018 at 10:11

1 Answer 1

2

For anybody has the same issue,

it's local docker memory limit. My docker was allowed to use 2Gb of memory max so JVM was not able to allocate more than 1.74Gb of memory.

I increased memory that docker can use, now, JVM allocates 3.43Gb of heap for 4Gb of container memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.