I've a container which is running a java application with the following jvm arguments:
-XX:+UseG1GC -Xms512m -Xmx2048m -XX:MaxPermSize=256m
I'm using docker memory limit option:
docker run -it -m 2304m foo bash
Running docker stats myApp
right after the container initialization will give me:
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
myApp 0.17% 660.5 MB/2.416 GB 27.34% 240.8 kB/133.4 kB
But after a few hours I've the following stats:
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
myApp 202.18% 2.416 GB/2.416 GB 100.00% 27.67 GB/19.49 GB
Although, If I look into the process execution details of the running application inside the container, I have an usage of ~735MB
and myApp continues to compute requests without any problems:
me@docker-container ~]$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
me+ 1 0.0 0.0 11636 1324 ? Ss 13:44 0:00 /bin/bash /home/bar/service/start-myApp.sh
me+ 6 113 4.5 5014152 735736 ? Sl 13:44 438:46 java -XX:+UseG1GC -Xms512m -Xmx2048m -XX:MaxPermSize=256m -jar myApp-service-1.0-final.jar
me+ 481 0.0 0.0 11768 1820 ? Ss 20:09 0:00 bash
me+ 497 0.0 0.0 35888 1464 ? R+ 20:10 0:00 ps aux
Worthy to mention that I've used jconsole to monitor process 6
and everything looks good.
Why is docker container using all the memory available if its content does not need it? I expected that docker would use a little more memory than myApp... not 100% of the available memory.