1

I am experiencing an issue at my company's application where a docker container has memory that continues to grow until an OOM error occur and the container restarts. It seems to indicate there is a memory leak in the code for that container.

It is a java application that is mainly sending/receiving/processing kafka events, we were able to reproduce this behaviour by simulating a large number of events. And it's using zookeeper to store some event data.

Things I have tried:

  1. using jprofiler attached to the container. (jprofiler shows container memory is stable, no indication of memory leak, memory constantly being garbage collected.
  2. inspecting code for that container, nothing I have noticed that would cause a memory leak.

I wonder if someone who has experience in similar setup would advice me for the possible causes of the memory issue, and where/what I should be checking as my next step.

Is it possible the memory issue is not related to the code but the docker system? I'm thinking of running that application as a standalone service and see if the same behaviour will be observed.

2
  • 2
    Check if the memory of the JVM is properly configured to fit inside the container's limits. Even if there is no leak, the simple fact of churning data will make the JVM's heap grows until the GC work is "comfortable", possibly reaching the maximum of the heap memory. If that maximum is not properly configured (with -Xmx for example), it could be higher than what your container is allowed to have. Maybe you will find answers in this related question stackoverflow.com/questions/63133649/… Commented May 27 at 5:29
  • If you are running old versions of Java 8, this is common. Switch to at least 17 Commented May 28 at 20:11

1 Answer 1

0

Not sure if this applies to your specific situation but

In your program if you are using multithreading/executors which don't terminate or hang or tasks, you can end up with orphaned threads. You could check if you are using these and enforce a limit on how many can be created, forcing older inactive threads to be closed

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.