docker memory consumption
Closed this issue · 2 comments
Using the current master branch, the docker container uses more than 500 MB of RAM even at the start when nothing is happening:
$ docker build -t lodview .
$ docker run --network=host --privileged -d lodview
$ docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
413bd2f64fca sweet_leavitt 0.00% 529.5MiB / 15.42GiB 3.35% 0B / 0B 57.6MB / 0B 36
Output of top from within the container:
top - 09:03:30 up 51 min, 0 users, load average: 0.87, 0.95, 0.73
Tasks: 3 total, 1 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 7.9 us, 2.1 sy, 0.0 ni, 89.8 id, 0.0 wa, 0.1 hi, 0.1 si, 0.0 st
MiB Mem : 15791.6 total, 7311.0 free, 3588.6 used, 4892.0 buff/cache
MiB Swap: 16384.0 total, 16384.0 free, 0.0 used. 9873.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 1 0 8060128 536560 20060 S 0.3 3.3 0:13.90 java
47 root 1 0 5756 3604 3108 S 0.0 0.0 0:00.08 bash
59 root 1 0 9768 3368 2844 R 0.0 0.0 0:00.01 top
# java -XX:+PrintFlagsFinal -version | grep -E "UseContainerSupport | InitialRAMPercentage | MaxRAMPercentage | MinRAMPercentage"
double InitialRAMPercentage = 1.562500 {product}
double MaxRAMPercentage = 25.000000 {product}
double MinRAMPercentage = 50.000000 {product}
bool UseContainerSupport = true {product}
# jinfo 1 | grep "VM flags"
Non-default VM flags: -XX:CICompilerCount=4 -XX:InitialHeapSize=260046848 -XX:MaxHeapSize=4139778048 -XX:MaxNewSize=1379926016 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=86507520 -XX:OldSize=173539328 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseParallelGC
Is there a way to reduce the usage?
VisualVM
$ docker run --network=host --privileged -d -e CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost" lodview
Opening a few tabs at the same time:
- http://localhost:8080/lodview/Berlin.html
- http://localhost:8080/lodview/Moscow.html
- http://localhost:8080/lodview/Leipzig.html
- http://localhost:8080/lodview/Dresden.html
Heap
Garbage collection was manually performed at the end.
Serial garbage collector seems to be much better suited to minimize RAM usage.
docker run --network=host --privileged -e CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost -XX:+UseSerialGC" lodview
Opening the same tabs as before.
Reduced somewhat by #55.