Wrong memory usage reported for LXC running VMs

citral

New Member
Nov 26, 2024
2
0
1
Hello, for a very specific use case I have a debian LXC running virt-manager with 4 windows VMs.

In the summary of the LXC on the admin web console, it reports only 2.97% (974.54 MiB of 32.00 GiB) of RAM used.

whereas free -m in the LXC outputs:

total used free shared buff/cache available
Mem: 32768 25485 128 24509 31664 7282


And all tools like btop also report a usage of around 25G

Do you know what tool in proxmox is evaluating it, and if there's a fix?
 
Sorry, but my previous answer was totally wrong.

For Containers, we read the values from /sys/fs/cgroup/CTID/ (memory.stat and memory.current).
This is because container memory is limited by the cgroup kernel system.

Tools like "free" or "btop" use kernel syscalls, which simple return the memory usage from the host.
 
Tools like "free" or "btop" use kernel syscalls, which simple return the memory usage from the host.
they usually parse /proc/meminfo, which is provided by lxcfs and should also take cgroups into account (for those fields where it matters, some are just passed through from the host /proc/meminfo).

could you post /proc/meminfo from both host and guest?
 
Sure, Host:
Code:
MemTotal:       528087452 kB
MemFree:        456239144 kB
MemAvailable:   462559996 kB
Buffers:          285476 kB
Cached:         33845332 kB
SwapCached:            0 kB
Active:         51671804 kB
Inactive:       14425908 kB
Active(anon):   50339128 kB
Inactive(anon):  6824976 kB
Active(file):    1332676 kB
Inactive(file):  7600932 kB
Unevictable:      209036 kB
Mlocked:          203292 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:               324 kB
Writeback:            16 kB
AnonPages:      32176552 kB
Mapped:         25741560 kB
Shmem:          25175300 kB
KReclaimable:     388856 kB
Slab:            1044876 kB
SReclaimable:     388856 kB
SUnreclaim:       656020 kB
KernelStack:       34032 kB
PageTables:       177208 kB
SecPageTables:     71736 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    264043724 kB
Committed_AS:   81265272 kB
VmallocTotal:   34359738367 kB
VmallocUsed:     2152992 kB
VmallocChunk:          0 kB
Percpu:            76800 kB
HardwareCorrupted:     0 kB
AnonHugePages:  27865088 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
Unaccepted:            0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      469500 kB
DirectMap2M:    11849728 kB
DirectMap1G:    526385152 kB

LXC:
Code:
MemTotal:       33554432 kB
MemFree:          132068 kB
MemAvailable:    7418520 kB
Buffers:               0 kB
Cached:         32372976 kB
SwapCached:            0 kB
Active:         26195144 kB
Inactive:        6832676 kB
Active(anon):   25732412 kB
Inactive(anon):     8956 kB
Active(file):     462732 kB
Inactive(file):  6823720 kB
Unevictable:           0 kB
Mlocked:          203292 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        655132 kB
Mapped:                0 kB
Shmem:          25086236 kB
KReclaimable:     387808 kB
Slab:                  0 kB
SReclaimable:          0 kB
SUnreclaim:            0 kB
KernelStack:       34928 kB
PageTables:       178024 kB
SecPageTables:     71744 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    264043724 kB
Committed_AS:   81775160 kB
VmallocTotal:   34359738367 kB
VmallocUsed:     2155624 kB
VmallocChunk:          0 kB
Percpu:            76800 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
Unaccepted:            0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      469500 kB
DirectMap2M:    11849728 kB
DirectMap1G:    526385152 kB

free -m today on LXC:
Code:
               total        used        free      shared  buff/cache   available
Mem:           32768       25521         129       24498       31614        7246
Swap:              0           0           0
 
Last edited:
our stats don't count the page cache, whereas /proc/meminfo gives a more detailed view that allows free to give a more detailed picture as well.. I am not sure whether this is fixable without providing a more detailed view as well..