Memory is fast and expensive but unused and wasted while it is "free", IMHO.
I get your point for bare metal installations but in virtual environments that caching is really annoying. I'm really missing a option to limit the cache size to a fixed value (like the ZFS ARC) but linux isn't offering this. Only way to prevent this is to assign the RAM as small as possible so the VMs got enough RAM to run under normal circumstances but may then run into problems and start swapping or OOM killing is kicking in if a software suddenly needs alot of RAM and you don't expect that.
I thought balloning may help for that so VMs could share a little bit of RAM (overcommiting) to prevent such unexpected situations but it doesn't, because the algorithm is stupid and doesn't allocate the RAM to guests who really need it. It it just using fixed ratios no matter how much RAM is really used or free by each VM.
Would all be fine if balloning would lower the RAM of VMs with alot of cached data and would give to to VMs which are low on usable RAM. But that is unfortunately not how it works...
So overcommiting the RAM isn't really possible but would be very helpful if you already maxed out your RAM slots and the hosts RAM is always running at the limit. And because of that the VMs RAM don't got alot of margin and some VMs can run into OOM while other VMs are wasting 10GB and more by caching stuff...
buff cached for what? htop is also telling me 2.4Gb used against 32Gb yet the colored bar is showing me the 58%. I dont like caches if i cant control it.
running
echo 1 > /proc/sys/vm/drop_caches
frees that cache and everything runs to normal. I know its temporary and i should probably let it go...
If your VM only needs 2.4GB RAM you shouldn't assign 32GB or linux will "waste" all the space until the 32GB are full. Only way to prevent this is to run
echo 1 > /proc/sys/vm/drop_caches
every several minutes by cron but that way no caching will be used and your system will get really slow because everything will have to be loaded from the slow HDD/SDD instead of the fast RAM. It looks like there is no way to limit that caching so the most important files would be cached but not everything so not many GBs of RAM would be wasted.
You could try to reduce the RAM to 8 GB. That way your VM will always be at 95% RAM usage but atleast the cache can't be bigger then 5GB if your system and programs only need 2.4GB. By doing that you save 11GB or moe of RAM that won't be used for caching so your other VMs can use it instead.