Centos – Hyper-V: CentOS 6.6 guest with Dynamic Memory – Should I see memory decrease from guest OS

centoshyper-vmemory

I'm testing CentOS 6.6 in Hyper-V (W2K12R2) with dynamic memory.
I set Startup and Minimum Memory to 4096MB, Maximum Memory to 16384MB. 20% buffer size.

After boot I can see it's memory size as 3882MB from CentOS and memory demand is ~700MB in Hyper-V Manager on Host OS.

Than I tried to create couple of 2GB tmpfs mounts and filled them with random data. Since it was more than 4GB, memory size became to increase in guest OS and I saw memory size as 5996MB.

Than I erased everything from tmpfs directories and assigned memory on Host OS became 4096MB, demand memory 901MB. But memory size in CentOS stayed as 5996MB. Memory usage shown as 2940MB

Mem:   6140300k total,  3903940k used,  2236360k free,   116944k buffers
Swap:        0k total,        0k used,        0k free,   775396k cached

1. Should guest OS see memory decrease?

2. If it shouldn't, how can I figure out real memory size and memory usage from guest OS?

Best Answer

The guests will hang on to the existing memory until either the guest is rebooted or ballooning takes effect and the host "steals" back some of the RAM (which shows as used on the guest). This is likely because the OS doesn't respond as well to sudden "missing" RAM (similar to hot-add being a thing but removal requiring a reboot).