VMware Cloud Community
marknashe
Contributor
Contributor
Jump to solution

Swap File

Good day, I have a question about swap files. If I create a virtual machine with 1vcpu, 2gb ram, and am not using a resource pool, then I see that my swap file is 2GB in size. I understand that, so far. If I use memory reservation of 1GB, my swap will be 1GB. Understand that part as well. What I don't understand is, when this file will be used? I've read some links on web, and I see it has nothing to do with the windows page file. If I have a VM with 1GB of vram and all of that 1GB is being used, I would think that windows is going to start writing to the pagefile, which will kill performance. Unless I am wrong and that is  when this swap file is used?

Any assist?

MN

Reply
0 Kudos
1 Solution

Accepted Solutions
weinstein5
Immortal
Immortal
Jump to solution

There are three steps the vmkernel uses in managing and freeing up memory -

  1. Transparent Page Sharing - The vmkernel is aware of all pages bring stored by the VMs - when it identifies identical pages it will store them once in read only memory and when a change needs to be made it will be copied to its own space in memroy - this is completely transparent to the gueat operating system in the VM
  2. Balloon Driver - This is driver that is installed with VMware Tools and typically is inactive - it is activated by the vmkernel when the ESXi host is running hsort on physical memory - it starts claiming memory in the VMs virtual memory forcing the operating system to sue its own pagefile/swap space -
  3. per vm vmkernel swap file - what you are asking about - if the vmkernel does not have enough memory to satisfy the VMs needs it begins to swap memory pages to this swap space/ As you pointed out it is independent of the guest os virtual memory and is equal to the amount of memory assigned to the vm and the VMs memory reservation - so fi everything is functioning as designed yes the VM will already have been using the guest os virtual memory
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful

View solution in original post

Reply
0 Kudos
6 Replies
weinstein5
Immortal
Immortal
Jump to solution

There are three steps the vmkernel uses in managing and freeing up memory -

  1. Transparent Page Sharing - The vmkernel is aware of all pages bring stored by the VMs - when it identifies identical pages it will store them once in read only memory and when a change needs to be made it will be copied to its own space in memroy - this is completely transparent to the gueat operating system in the VM
  2. Balloon Driver - This is driver that is installed with VMware Tools and typically is inactive - it is activated by the vmkernel when the ESXi host is running hsort on physical memory - it starts claiming memory in the VMs virtual memory forcing the operating system to sue its own pagefile/swap space -
  3. per vm vmkernel swap file - what you are asking about - if the vmkernel does not have enough memory to satisfy the VMs needs it begins to swap memory pages to this swap space/ As you pointed out it is independent of the guest os virtual memory and is equal to the amount of memory assigned to the vm and the VMs memory reservation - so fi everything is functioning as designed yes the VM will already have been using the guest os virtual memory
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos
marknashe
Contributor
Contributor
Jump to solution

Thank you for quick reply. Just so I understand, if a a VM is set to 2GB of vram and the VM actually needs the 2GB, but the host does not have 2GB free to give the VM, that is when the swap file is used?

In regards to page file, should I assume if page file is being used, VM has not been configured with the appropriate amount of vRAM? Is there an easy way in vSphere client or on guest OS to see this?

My apology if these are elementary questions, as I'm still new to VMware, most of my past has been in other areas of IT

Reply
0 Kudos
weinstein5
Immortal
Immortal
Jump to solution

Thank you for quick reply. Just so I understand, if a a VM is set to 2GB of vram and the VM actually needs the 2GB, but the host does not have 2GB free to give the VM, that is when the swap file is used?

That is correct -

In regards to page file, should I assume if page file is being used, VM has not been configured with the appropriate amount of vRAM? Is there an easy way in vSphere client or on guest OS to see this?

I would not necessarily say it is sized incorrectly because a machine, virtual and physical, will constantly be using its swap file and the swap file might be used for momentary spikes -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
marknashe
Contributor
Contributor
Jump to solution

thank you. you have been very helpful

Reply
0 Kudos
marknashe
Contributor
Contributor
Jump to solution

One more question if you don't mind.

If I have VMs, say Windows XP set to 1GB of ram, and in vSphere client, it says consumed host memory of 1201, does that mean, I should be configuring them with 2GB, 1201MB is more than 1GB

Reply
0 Kudos
weinstein5
Immortal
Immortal
Jump to solution

There is a slight memory overhead that is needed by the vmkernel - 

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful