Hi,
I have a basic question about the memory consumption of lxc container, and would like to get some confirmation from this forum, can someone please help me understand it better? The question is this:
I notice the used memory reported by “free” (inside of container) is decreasing, as the number of the same container copies are increasing. All containers are copied from the same one, and all of them are idle. By just starting more containers in idle state, the used memory reported by free inside of the idle container is getting smaller (I would think it should remain the same since the container itself is idle). Here is an example
started one copy
ubuntu@guiapps:~$ free -h
total used free shared buff/cache available
Mem: 953Mi 102Mi 724Mi 0.0Ki 125Mi 850Mi
Swap: 953Mi 0.0Ki 953Mi
the above showing that the used memory is 102MB.
started another one, currently two are idle, type free in the above container, here is the result
$ free -h
total used free shared buff/cache available
Mem: 953Mi 70Mi 868Mi 0.0Ki 14Mi 883Mi
Swap: 953Mi 27Mi 925Mi
“used” field is showing 70MB, the only difference in the host, comparing with the previous “free” is another copy of this container is started.
I understand /proc/meminfo and free are correctly containerized already, so they will report the used memory correctly. But I am a bit unsure about the above behavior. I am wondering if this is because of the memory accounting - same resources are shared among the same containers, so that more copies will amortize the used memory for each? It would be great if some one can help me understand this better, or some pointers/tools/commands so that I can further look at this?
Thank you in advance!