5

I've set up a virtual machine through KVM-libvirt (virt-manager) with Windows 10 on it and I'm getting an odd behavior on the host side. I'm running a 64bit Arch host with 24GB of RAM, 12 of which are allocated to it and the other 12 to the VM.

After starting up the VM and letting it sit for a while, not too long maybe an hour so, my entire host's remaining RAM gets buffered/cached. For instance, right now I get this from free -m:

              total        used        free      shared  buff/cache   available
Mem:          24064       13887         253         110        9923        9957
Swap:          4095        1313        2782

Before starting the VM I had a couple of applications running, but they didn't amount to more than 2GB or so of RAM, and nothing new has been opened since then, just some normal web browsing (writing this question actually).

Now, I've read around a lot about linux caching RAM because free RAM is wasted RAM and whatnot, but this is causing almost everything that's running on the host to get swapped. And that is a big problem for me because everything gets so slow.

As far as I can tell, RAM caching should not cause memory to be swapped. I know linux is supposed to be smarter than me about efficient memory utilization, such as how I shouldn't clear the swap and/or cache... but, having everything swapped out thus slowing down the system considerably doesn't sound smart nor efficient to me.

What could possibly be going on? Is linux caching the VM disk accesses and that's why it's always using the entire remainder of my RAM? The VM is installed in a disk image, should I try using a separate physical disk for it?

  • Disabling the swap space is one fairly blunt way to stop Linux from scittering bits off to disk... – thrig Nov 6 '15 at 0:48
  • 1
    search this site for swappiness: unix.stackexchange.com/search?q=swappiness – cas Nov 6 '15 at 1:12
  • Thank you, I know about it, but I'd rather know why it's swapping memory rather than lowering the swappiness. My understanding is that as long as there's buffered/cached RAM it shouldn't use swap, is that correct? – elpato Nov 6 '15 at 10:58
  • As long as there's available memory, it will be used, to hold in flight data, and avoid too much disk activity. – dyasny Nov 6 '15 at 17:26
  • Then, is there any way to prevent it from using swap if there's cached RAM available? I don't mean lowering the swappiness because I'm perfectly fine with linux using swap when it's run out of memory, but not when there's clearly plenty available somewhere else... – elpato Nov 6 '15 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.