How to make reported LXC memory usage include its cache/buffer?

YungErrorHunter

New Member
Dec 10, 2023
14
2
3
The reported memory usage of a VM in its summary and graphs includes RAM used by caching inside a VM.

The reported memory usage of a node in its summary includes RAM used by caching inside VMs and LXCs.

The reported memory usage of an LXC in its summary does not include RAM used by caching.

Is this some technical limitation, an intended feature, a bug, or simply something I can easily change? I would prefer if the memory usage reported for an LXC would behave like it does with VMs, so it's easy for me to see how much actual RAM is taken from the host by a given LXC.

(In case it matters: postgresql running inside an LXC is using 16GB of RAM for caching, however the GUI reports that the LXC is only using 2GB of RAM at the moment. Those same 16GB are however included, as it should imo, in the node's RAM usage.)

From inside the LXC:
Code:
~# free -h
               total        used        free      shared  buff/cache   available
Mem:            32Gi        17Gi        14Gi        16Gi        16Gi        14Gi
Swap:             0B          0B          0B
 
I found this thread: https://forum.proxmox.com/threads/wrong-memory-usage-reported-for-lxc-running-vms.158035/ which, if I interpret it correctly, suggests that proxmox should be using the value from /sys/fs/cgroup/lxc/119/memory.current for LXC memory usage. (119 is my LXC id)

cat /sys/fs/cgroup/lxc/119/memory.current on the host (and cat /sys/fs/cgroup/memory.current within the LXC) both report almost 18GB, which is the amount of host memory the LXC is actually using at the moment (sum of used+cached) and which I'd want to be displayed on the LXC's summary and in its graphs, but somehow that is not the case.

Instead, it seems to be using the kernel value from /sys/fs/cgroup/lxc/119/memory.stat. I don't know if that's intended or not. Is there anything I can do to change this?