I faced an interesting problem trying to analyze a memory consumption in my Java application running on docker container vs host machine.
- The Java app is web app on the Jetty server 9.4.9
- Java version : 1.8
- Host : MAC
- Docker images: jetty:9.4-jre8
- The docker daemon is 18.03.1-ce version.
On the host I'm using Yourkit tool to analyze a memory consumption.
For docker container docker stats <docker id/name>
What I'm getting is that on MAC yourkit shows me 50M Non-heap size + ~40M heap size, in total ~100M
Whereas, when I deploy and run the same war on a container, the stats shows me 200M
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
879fb113ca8d jetty-app 0.19% 214.6MiB / 1.952GiB 10.74% 1.49MB / 88.9kB 31.7MB / 6.42MB 29
Can anyone shed some light on this phenomenon?
Assuming that stats
provides wrong results, I tried to limit the memory on a container using --memory
flag doesn't help much, I'm getting OOM.
Thanks in advance
yourkit
anddocker stats
might be useful. – Misbeliefdocker stats
might be including memory used by the threads stacks - this is by default 1MB per thread and is not included in heap memory or non-heap memory, so I would recommend checking thread count in yourkit. 3. Heap memory shown by yourkit looks a bit weird - although app is using only 25MB of heap memory, it might have more than that reserved (green line looks like 75MB). – Misbelief