Nexus Docker container eating up all of my hosts's memory?

Nexus v 3.32.0-03

I have a dedicated Linux Ubuntu host with 32G memory running my Nexus server, which I configured to run as a Docker container, which I start this way.

docker run --rm -d -p 8081:8081 --memory 16g --name nexus -v nexus-data:/nexus-data sonatype/nexus3

For some reason, it just eats up all my systems’s memory despite of the --memory 16g flag. I restarted my host last night, and today I see this. htop shows a bunch of PIDs from user 200 that use 5G memory.

$ free -g
              total        used        free      shared  buff/cache   available
Mem:             31          22           5           0           3           8
Swap:            39           0          39

What can I do to prevent this? Thanks!

I’ll try this from Docker Hub

docker run --rm -d -p 8081:8081 -e INSTALL4J_ADD_VM_PARAMS="-Xms6G -Xmx6G -XX:MaxDirectMemorySize=15530M" --name nexus -v nexus-data:/nexus-data sonatype/nexus3

That didn’t help.

I have the same problem (running it in a container on Kubernetes/Docker) since I’ve upgraded to CentOS9. Nexus (v3.42.0) eats up all the memory after a few days till it gets killed by the OOM killer. I’ve set the Java runtime parameters according to the documentation but the memory went up till 70Gi again.

-Xms8G
-Xmx8G
-XX:+UseG1GC
-XX:MaxDirectMemorySize=35158M

Can it maybe be related to the ulimit for the number of open files? I’ve set it to around 1 million cause the documentation just said more than 65k?

This isn’t a widely reported problem we’ve heard of, if you’re a pro customer you should open a ticket.

As an OSS user you’d need to do a heap dump and use an analyzer try to figure out what is consuming the memory.

You should be careful if your instance is getting regularly killed as that can lead to database corruption. It may be worth looking into repairing it now as perhaps some corruption there is leading to the out of control memory usage.

What is the correct approach the repair the database? I’ve tried Fix Sonatype Nexus OrientDB · GitHub?

It seems as everytime there is a bigger upload e.g. docker push the memory usage increases and stays there. Is that normal behaviour?