Use this when deciding which VMs keep memory when a host runs short.
Memory Shares
Memory shares decide which VMs keep their memory when the host runs short: under pressure, VMs with fewer shares are ballooned or swapped first. They do nothing while the host has free memory.
1. Memory shares decide who loses memory under pressure.
2. Only matter during contention.
3. Higher for important VMs.
4. Combine with right-sizing.
5. Monitor reclaim per VM.
pressure → shares → reclaim targets
Context & applicabilityCommon mistakes · platform/version boundaries
- Changing shares without contention, expecting faster VMs.
- Resource pool shares diluted by many VMs.
- Ignoring idle memory tax, which reclaims idle memory first.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Shares only act under pressure.
- Low shares = reclaimed first.
- Pool shares split among VMs.
Set-VMMemory <vm> -Priority 80— Hyper-V memory weightvirsh memtune <vm> --soft-limit— libvirt soft limitGet-VMResourceConfiguration (PowerCLI)— vSphere shares
ReferenceWhy it matters1 section · depth on demand
How shares work
Shares only matter when memory is contended. Values are relative (on ESXi: Low 5, Normal 10, High 20 shares per MB of configured memory). A VM with High shares keeps more memory than a Normal one under pressure. In resource pools, shares are divided among the VMs in the pool, so a pool with many VMs can give each VM less than expected.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Memory shares set priority for reclaiming memory under host pressure: VMs with fewer shares (relative to their size and idle memory) are ballooned or swapped first. VMware also applies an idle memory tax so idle memory is reclaimed before active memory.
In Hyper-V, "Memory weight" with dynamic memory decides which VMs get memory first when demand exceeds supply. Give infrastructure and production VMs higher shares/weight than test VMs.
Example
Host with 64 GB under pressure: VM A (High, 16 GB), VM B (Normal, 16 GB). Memory shares are 20 (High), 10 (Normal) and 5 (Low) per configured MB, so A has 20 × 16,384 = 327,680 shares and B 10 × 16,384 = 163,840. Under contention A gets about twice B's share of the reclaimable memory, after reservations are met and minus idle memory tax on inactive pages.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Resource Management → Memory Shares. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/html/libvirt-libvirt-domain.html · confidence 94%