"Missing" memory on Linux VMs but not on Windows ones

Oct 7, 2019
779
311
108
Spain
I've just noticed that Linux VMs get less usable memory than that configured in the VM. For example, for a VM with 512MiB, top/htop/free shows just 466MiB (lost aprox 9%). For a 4GiB VM, only 3915.3MiB is available to the OS (lost 2.1%). A 128MiB VM will lose like 23% and give just 98.3MiB for Linux to use.

With the exact same VM but running Win10 or Win2019, task manager and resource monitor shows all the memory (4GiB). Maybe Windows is rounding up the values?

Using qm showcmd I can see a parameter "-m 4096". AFAIK, the webUI, Linux top/htop/free and Windows task manager show values in MiB/GiB. I think that QEMU command line uses MB/GB. Still, the unit conversions don't match the values in Linux:

512MB=488,281MiB
4096MB=3906,25MiB

I'm probably overlooking something on this one, but still wondering why Linux VMs get less memory than that configured and running in QEMU.

edit:
- This is the VM config:
Code:
agent: 1,fstrim_cloned_disks=1
boot: order=scsi0;ide2;net0
cores: 3
cpu: host
ide2: none,media=cdrom
machine: q35
memory: 2048
name: Memtesting
net0: virtio=2A:A9:1E:93:1E:01,bridge=vmbr1
numa: 1
ostype: l26
protection: 1
scsi0: NVME:vm-980001-disk-0,discard=on,iothread=1,size=20G,ssd=1
scsihw: virtio-scsi-single
smbios1: uuid=356a49b8-2109-4637-b03e-3933af8e211b
sockets: 1
vmgenid: 25fe2ff2-8910-43b4-a246-b0f366733d5d

- I've seen this on PVE8, PVE7.4. PVE7.2 and PVE6.3 with a variety of kernel and QEMU versions.
 
Last edited:
The kernel reserves some of the memory for itself, free only shows the total amount of memory available to processes. When checking dmesg (or the journal) you can find a line near the beginning, that looks something like this:

Code:
Memory: 3930860K/4193760K available (20480K kernel code, 4127K rwdata, 12376K rodata, 4704K init, 17624K bss, 262640K reserved, 0K cma-reserved)
 
  • Like
Reactions: VictorSTS

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!