VMware Memory Management Part 3 – Memory Ballooning

This post we are going to understand in detail about Memory Ballooning. Memory Ballooning is one of the common question which are asked during VMware Administrator interviews to test the knowledge of the candidate because there are lot of misunderstanding out there about this feature. So, decided to explain about VMware Memory Ballooning in simple and understandable manner.

VMware Memory Ballooning is one of memory reclamation technique used by hypervisor, when ESXi host is running low on memory. We have discussed in detail about ESXi host Memory states in my previous post “Understanding ESXi Host Memory States”. When the ESXi host memory state is High, None of the action will be taken by hypervisor expect Transparent page sharing. In understand about Transparent Page sharing, take a look at my post “Understanding TPS”. Memory Ballooning will be active, if your ESXi host Memory state is soft.

vSphere 6.5 Blog posts:

What’s New with VMware vSphere 6.5?
vSphere 6.5 -What’s New with vCenter 6.5?
What’s New with Virtual SAN 6.5? – New Features Overview
vSphere 6.5 -What’s New with vSphere 6.5 HA & DRS
vSphere 6.5 – What’s is in VMware vSphere 6.5 Fault Tolerance?
Download VMware vSphere 6.5 – Get your Copy to Evaluate!!!
vSphere 6.5 – Deploying vCenter appliance 6.5
Deploying vCenter 6.5 External Platform Services Controller
Deploying vCenter Server appliance 6.5 with External PSC
vSphere 6.5 – Configuring vCenter Server 6.5 HA
vSphere 6.5 – vCenter 6.5 Native HA Failover Testing
vSphere 6.5 Configuration Maximums – What’s New?
vSphere 6.5 – How VM’s are Secured using vSphere 6.5 Security Features?
Migrate Windows vCenter Server 6.0 to vCenter Server appliance 6.5

Memory Ballooning is the memeory reclamation technique used by hypervisor to reclaim the memory back from the virtual machine. Ballooning will happen on the ESXi host which is running out of physical memory or  its memory state is soft. In Virtualization, ESXi host doesn’t know what guest operating is performing and also Guest does not aware that it is running on virtual machine. Then how does ESXi host will request the memory back form the guest operating system? . Thats where balloon driver come into picture. There is balloon driver called vmmemctl.sys which is running on the virtual machine which is available as part of VMware Tools. When ESXi host running low on physical memory, It uses ballooning driver (vmmemctl.sys) to determine the how much memory from virtual machines can be get back to prevent the hypervisor swapping.

Before I explain about Memory ballooning in detail, I would like explain 3 Memory terminologies which you should understand to better understand the Memory ballooning.

1. Host Physical Memory : Memory which is visible to your ESXi host or in other terms available on the your physical server or system

VMware Memory Terminology

2. Guest Physical Memory : Memory which is visible to your Guest operating system running in the VM. Let’s say , you have created a VM called VM1 with 4 GB of memory. Guest OS will see 4 GB of memory, which is referred to as Guest Physical memory.

3. Guest Virtual Memory : Guest Virtual memory mostly visible to your applications running inside the Virtual machine. Guest Virtual Memory refers to a continuous virtual address space presented by the guest operating system to applications.

Memory Ballooning with Real- Time Example:


Memory Ballooning
1. You are running a virtual Machine called ” VM1″ and You are starting a application called Microsoft Excel on that VM. Microsoft Excel as an application will ask the windows guest operating system for memory. Windows will provide the memory to the application and map it from the  Guest virtual memory -> guest physical memory

2. When the  Guest Virtual Memory is mapped Guest Physical memory, Hypervisor sees the request for memory from guest and hypervisor maps guest physical memory -> Host physical memory. You are generating report on Microsoft Excel application for around 2 hours and  closed the application ,once you have done with it.

3. When you close the Microsoft Excel, Guest operating system will mark the memory allocated to Microsoft excel as “free” and make it available for other applications running on the guest OS but your hypervsior will not aware aware about the “free memory list” of your guest OS, so it keeps the memory mapped in the host physical memory and which puts the memory load on the ESXi host.

4. So When ESXi host is running low on memory or ESXi host memory state is Soft, VMware Memory Ballooning comes into picture. Hypervisor will ask the balloon driver installed inside the virtual machine to “inflate” . Since, memory ballooning driver is running on the guest operating system, It will get the memory from the “free list”. Hypervisor will detect the memory reclaimed by the balloon driver and will free it up on the host physical memory layer and provides that physical memory to other virtual machines which is in need of memory instead of swapping it into disk. By default, Balloon driver (vmmemctl.sys) can reclaim upto a maximum of 65 % of guest physical memory. For example, You VM is allocated with 1000 MB of memory, It can be reclaimed upto 650 MB using this technique.

Analyzing Memory Ballooning Statistics:

You can verify the memory ballooning  stats from Esxtop ,Virtual Machine Resource Allocation tab and also using vCenter Performance Graphs.

esxtop -> Press m

You will see the “MEMCTL/MB” counter which shows us the overall ballooning activity (22110 MB). The “curr” and “target” values are the accumulated values of the “MCTLSZ” and “MCTLTGT” as described below.

Memory Balloning_1We have to look for the “MCTL” columns to view ballooning activity on a per VM basis:

“MCTL?”: indicates if the balloon driver is active “Y” or not “N”. If VMware tools is not installed or not running this value will show as “N”

“MCTLSZ”: the amount (in MB) of guest physical memory that is actually reclaimed by the balloon driver

“MCTLTGT”: the amount (in MB) of guest physical memory that is going to be reclaimed (targeted memory). If this counter is greater than “MCTLSZ”, the balloon driver inflates causing more memory to be reclaimed. If “MCTLTGT” is less than “MCTLSZ”, then the balloon will deflate. This deflating process runs slowly unless the guest requests memory.

“MCTLMAX”: the maximum amount of guest physical memory that the balloon driver can reclaim. Default is 65% of assigned memory.

Resource Allocation Tab:

You can verify the Memory Ballooning stats of each individual VM from VM Resource Allocation Tab. This particular VM  Ballooned value is 5.08 GB

Memory Balloning_2vCenter Performance Charts:

You can generate a custom vCenter performance charts to understand the Memory ballooning stats of all virtual virtual in the ESXi host or individual Virtual machines.

Memory Balloning_3

Memory Balloning_4I hope this post will help you to better understand the concept of Memory Ballooning. Thanks for Reading !!!. Be Social and share it in social media, If you feel worth sharing it.

vCenter Server Appliance 6.5 Posts

The Ultimate Revelation Of Reset VCSA 6.5 Root Password in 60 seconds
6 Basic Commands to Interact with VCSA 6.5 Embedded VPostgres Database
6 Tips for Configuring Firewall To Manage VCSA 6.5 Postgres Database Remotely You Can Learn From VMwareArena
How to Connect VCSA 6.5 Embedded Postgres Database using pgAdmin (With GUI) -VMware Unsupported
WinSCP Connection to VCSA failed – “Received too large SFTP packet”
How to Backup vCenter Appliance 6.5 Embedded Postgres Database
How to Monitor vCenter Server Appliance 6.5 performance using vimtop
Become an Expert on vCenter Server appliance Log File Location in 120 seconds
How to Backup And Restore VCSA 6.5 – The Ultimate Cheatsheet
How to Join VCSA 6.5 to Active Directory Domain from Web Client
How to Configure Active Directory Authentication for vCenter Server 6.5