Citrix Hypervisor

VM memory

When you create a VM, a fixed amount of memory is allocated to the VM. You can use Dynamic Memory Control (DMC) to improve the utilization of physical memory in your Citrix Hypervisor environment. DMC is a memory management feature that enables dynamic reallocation of memory between VMs.

XenCenter provides a graphical display of memory usage in its Memory tab. For more information, see the XenCenter documentation.

Dynamic Memory Control (DMC) provides the following benefits:

  • You can add or delete memory without restarting the VMs, providing a seamless experience to the user.

  • When servers are full, DMC allows you to start more VMs on these servers, reducing the amount of memory allocated to the running VMs proportionally.

What is Dynamic Memory Control (DMC)?

Citrix Hypervisor DMC works by automatically adjusting the memory of running VMs, keeping the amount of memory allocated to each VM between specified minimum and maximum memory values, guaranteeing performance, and permitting greater density of VMs per server.

Without DMC, when a server is full, starting additional VMs fail with “out of memory” errors. To reduce the existing VM memory allocation and make room for more VMs, edit each VM’s memory allocation and then restart the VM. When using DMC, Citrix Hypervisor attempts to reclaim memory by automatically reducing the current memory allocation of running VMs within their defined memory ranges. Citrix Hypervisor attempts to reclaim memory even when the server is full.

Notes:

Dynamic Memory Control is not supported with VMs that have a virtual GPU.

The concept of dynamic range

For each VM, the administrator can set a dynamic memory range. The dynamic memory range is the range within which memory can be added/removed from the VM without requiring a restart. When a VM is running, the administrator can adjust the dynamic range. Citrix Hypervisor always guarantees to keep the amount of memory allocated to the VM within the dynamic range. Therefore adjusting it while the VM is running may cause Citrix Hypervisor to adjust the amount of memory allocated to the VM. The most extreme case is where the administrator sets the dynamic min/max to the same value, forcing Citrix Hypervisor to ensure that this amount of memory is allocated to the VM. If new VMs are required to start on “full” servers, running VMs have their memory ‘squeezed’ to start new ones. The required extra memory is obtained by squeezing the existing running VMs proportionally within their pre-defined dynamic ranges

DMC allows you to configure dynamic minimum and maximum memory levels – creating a Dynamic Memory Range (DMR) that the VM operates in.

  • Dynamic Minimum Memory: A lower memory limit that you assign to the VM.

  • Dynamic Higher Limit: An upper memory limit that you assign to the VM.

For example, if the Dynamic Minimum Memory was set at 512 MB and the Dynamic Maximum Memory was set at 1,024 MB, it gives the VM a Dynamic Memory Range (DMR) of 512–1024 MB, within which it operates. Citrix Hypervisor guarantees always to assign each VM memory within its specified DMR when using DMC.

The concept of static range

Many operating systems that Citrix Hypervisor supports do not fully ‘understand’ the notion of dynamically adding or deleting memory. As a result, Citrix Hypervisor must declare the maximum amount of memory that a VM is asked to consume at the time that it restarts. Declaring the maximum amount of memory allows the guest operating system to size its page tables and other memory management structures accordingly. This introduces the concept of a static memory range within Citrix Hypervisor. The static memory range cannot be adjusted when the VM is running. For a particular boot, the dynamic range is constrained such as to be always contained within this static range. The static minimum (the lower bound of the static range) protects the administrator and is set to the lowest amount of memory that the OS can run with Citrix Hypervisor.

Note:

We recommend that you do not change the static minimum level as the static minimum level is set at the supported level per operating system. See the memory constraints table for more details.

Setting a static maximum level higher than a dynamic max allows you to allocate more memory to a VM in future without restarting the VM.

DMC behavior

Automatic VM squeezing

  • If DMC is not enabled, when hosts are full, new VM starts fail with ‘out of memory’ errors.

  • When DMC is enabled, even when hosts are full, Citrix Hypervisor attempts to reclaim memory by reducing the memory allocation of running VMs within their defined dynamic ranges. In this way, running VMs are squeezed proportionally at the same distance between the dynamic minimum and dynamic maximum for all VMs on the host

When DMC is enabled

  • When the host’s memory is plentiful - All running VMs receive their Dynamic Maximum Memory level

  • When the host’s memory is scarce - All running VMs receive their Dynamic Minimum Memory level.

When you are configuring DMC, remember that allocating only a small amount of memory to a VM can negatively impact it. For example, allocating too little memory:

  • Using Dynamic Memory Control to reduce the amount of physical memory available to a VM can cause it to restart slowly. Likewise, if you allocate too little memory to a VM, it can start slowly.

  • Setting the dynamic memory minimum for a VM too low can result in poor performance or stability problems when the VM is starting.

How does DMC work?

Using DMC, it is possible to operate a guest virtual machine in one of two modes:

  1. Target Mode: The administrator specifies a memory target for the guest. Citrix Hypervisor adjusts the guest’s memory allocation to meet the target. Specifying a target is useful in virtual server environments, and in situations where you know exactly how much memory you want a guest to use. Citrix Hypervisor adjusts the guest’s memory allocation to meet the target you specify.

  2. Dynamic Range Mode: The administrator specifies a dynamic memory range for the guest. Citrix Hypervisor selects a target from the range and adjusts the guest’s memory allocation to meet the target. Specifying a dynamic range is useful in any situation where you want Citrix Hypervisor to repartition host memory dynamically in response to changing numbers of guests, or changing host memory pressure. Citrix Hypervisor selects a target from within the range and adjusts the guest’s memory allocation to meet the target.

Note:

It is possible to change between target mode and dynamic range mode at any time for any running guest. Specify a new target, or a new dynamic range, and Citrix Hypervisor takes care of the rest.

Memory constraints

Citrix Hypervisor allows administrators to use all memory control operations with any guest operating system. However, Citrix Hypervisor enforces the following memory property ordering constraint for all guests:

0 < memory-static-min <= memory-dynamic-min <= memory-dynamic-max <= memory-static-max

Citrix Hypervisor allows administrators to change guest memory properties to any values that satisfy this constraint, subject to validation checks. However, in addition to the previous constraint, we support only certain guest memory configurations for each supported operating system. The range of supported configurations depends on the guest operating system in use. Citrix Hypervisor does not prevent administrators from configuring guests to exceed the supported limit. However, customers are advised to keep memory properties within the supported limits to avoid performance or stability problems. For detailed guidelines on the minimum and maximum memory limits for each supported operating system, see Guest operating system support.

Warning:

When configuring guest memory, we advise NOT to exceed the maximum amount of physical memory addressable by your operating system. Setting a memory maximum that is greater than the operating system supported limit can lead to stability problems within your guest.

The dynamic minimum must be at least 75% of the static maximum for all supported operating systems. A lower limit can lead to stability problems. Administrators are encouraged to calibrate the sizes of their VMs carefully, and ensure that their working set of applications function reliably at dynamic-minimum.

xe CLI commands

Display the static memory properties of a VM

  1. Find the UUID of the required VM:

    xe vm-list
    <!--NeedCopy-->
    
  2. Note the uuid, and then run the command param-name=memory-static

    xe vm-param-get uuid=uuid param-name=memory-static-{min,max}
    <!--NeedCopy-->
    

    For example, the following displays the static maximum memory properties for the VM with the UUID beginning ec77:

    xe vm-param-get uuid= \
        ec77a893-bff2-aa5c-7ef2-9c3acf0f83c0 \
        param-name=memory-static-max;
        268435456
    <!--NeedCopy-->
    

    The example shows that the static maximum memory for this VM is 268,435,456 bytes (256 MB).

Display the dynamic memory properties of a VM

To display the dynamic memory properties, follow the procedure as above but use the command param-name=memory-dynamic:

  1. Find the UUID of the required VM:

    xe vm-list
    <!--NeedCopy-->
    
  2. Note the uuid, and then run the command param-name=memory-dynamic:

    xe vm-param-get uuid=uuid param-name=memory-dynamic-{min,max}
    <!--NeedCopy-->
    

    For example, the following displays the dynamic maximum memory properties for the VM with UUID beginning ec77

    xe vm-param-get uuid= \
        ec77a893-bff2-aa5c-7ef2-9c3acf0f83c0 \
        param-name=memory-dynamic-max;
        134217728
    <!--NeedCopy-->
    

    The example shows that the dynamic maximum memory for this VM is 134,217,728 bytes (128 MB).

Update memory properties

Warning:

Use the correct ordering when setting the static/dynamic minimum/maximum parameters. In addition, you must not invalidate the following constraint:

0 < memory-static-min <= memory-dynamic-min <= memory-dynamic-max <= memory-static-max

Update the static memory range of a virtual machine:

xe vm-memory-static-range-set uuid=uuid min=value max=value
<!--NeedCopy-->

Update the dynamic memory range of a virtual machine:

xe vm-memory-dynamic-range-set \
      uuid=uuid min=value \
      max=value
<!--NeedCopy-->

Specifying a target is useful in virtual server environments, and in any situation where you know exactly how much memory you want a guest to use. Citrix Hypervisor adjusts the guest’s memory allocation to meet the target you specify. For example:

xe vm-memory-target-set target=value vm=vm-name
<!--NeedCopy-->

Update all memory limits (static and dynamic) of a virtual machine:

xe vm-memory-limits-set \
      uuid=uuid \
      static-min=value \
      dynamic-min=value \
      dynamic-max=value static-max=value
<!--NeedCopy-->

Notes:

  • To allocate a specific amount memory to a VM that doesn’t change, set the Dynamic Maximum and Dynamic Minimum to the same value.
  • You cannot increase the dynamic memory of a VM beyond the static maximum.
  • To alter the static maximum of a VM, you must shut down the VM.

Update individual memory properties

Warning:

Do not change the static minimum level as it is set at the supported level per operating system. For more information, see Memory constraints.

Update the dynamic memory properties of a VM.

  1. Find the UUID of the required VM:

    xe vm-list
    <!--NeedCopy-->
    
  2. Note the uuid, and then use the command memory-dynamic-{min,max}=value

    xe vm-param-set uuid=uuid memory-dynamic-{min,max}=value
    <!--NeedCopy-->
    

The following example changes the dynamic maximum to 128 MB:

xe vm-param-set uuid=ec77a893-bff2-aa5c-7ef2-9c3acf0f83c0 memory-dynamic-max=128MiB
<!--NeedCopy-->
VM memory