Compute Engine allocates random access memory (RAM), referred to as *memory*,
to your virtual machine (VM) or bare metal instances when you create them. This
document explains how Compute Engine configures memory across machine
types, how hardware memory topology affects performance, and how you can
customize memory limits and manage costs for your workloads.

Other Google Cloud compute services manage memory in different ways:

- **Google Kubernetes Engine (GKE)** : in Autopilot mode, GKE manages node hardware, so you don't choose machine series or tune non-uniform memory access (NUMA); instead you set Pod memory `requests` and `limits`. In Standard mode, you pick Compute Engine machine types for node pools (where node allocatable memory is lower than instance RAM due to OS and `kubelet` reservations) and set Pod limits.
- **Cloud Run** : you don't manage VMs or hardware memory topology; you set a per-instance memory limit, which also covers the in-memory `/tmp` file system.
- **Batch** : you request memory per task (`memoryMib`) or specify a Compute Engine machine type, and Batch provisions the instances.
- **Cluster Director and Cluster Toolkit**: clusters run on Compute Engine machine series, so the host RAM, high-bandwidth memory (HBM), and NUMA concepts in this document apply to cluster nodes.

The machine-series, memory topology, customization, and pricing sections that
follow apply when you select or manage underlying Compute Engine
instances directly.

## Understand compute instance memory

System memory provides high-speed, volatile data storage that your compute
instance's processors access directly to run operating systems, applications,
and in-memory datasets. When you create a compute instance, the machine type
that you select determines the memory capacity, memory technology, and
memory-to-vCPU ratio.

### Memory units

For historical reasons, Google Cloud tools and documentation refer to
machine type memory as decimal megabytes (MB) and gigabytes (GB). However,
these units represent binary
[gibibytes (GiB)](https://wikipedia.org/wiki/Gibibyte) and
mebibytes (MiB), where 1 GB is 2^30^
bytes, or 1,024 MB.

When you configure memory for a custom machine type, the unit requirements and
conversions depend on the tool that you use. For additional detail, see
[Express memory in MB or GB](https://docs.cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type.md.txt#memory_units).

### Memory profiles of machine types

To help you match memory capacity to your workload, Compute Engine
organizes predefined machine types into distinct memory profiles based on their
memory-to-vCPU ratios:

- **High-CPU (`highcpu`)** : allocates from 1 to 3 GB of memory per vCPU. Choose `highcpu` machine types for compute-bound workloads such as batch processing, high-traffic web frontends, video encoding, and scientific modeling that require high processing concurrency with minimal memory footprints.
- **Standard (`standard`)** : allocates from 3 to 7 GB of memory per vCPU. Choose `standard` machine types for general-purpose workloads that require a balance of compute and memory resources, such as web and application servers, microservices, and mid-sized relational databases.
- **High-memory (`highmem`)** : allocates from 7 to 12 GB of memory per vCPU. Choose `highmem` machine types for memory-intensive workloads such as production databases, distributed in-memory caches, and data analytics engines.
- **Mega-memory (`megamem`), hyper-memory (`hypermem`), and ultra-memory (`ultramem`)** : available in the [memory-optimized machine family](https://docs.cloud.google.com/compute/docs/memory-optimized-machines.md.txt), these profiles provide the highest memory-to-vCPU ratios on Compute Engine:
  - `megamem`: from 12 to 15 GB of memory per vCPU.
  - `hypermem`: from 15 to 24 GB of memory per vCPU.
  - `ultramem`: from 24 to 31 GB of memory per vCPU.
  - Bare metal ultra-memory (`-metal`): X4 and X5 bare metal instances provide from 6 TB to 48 TB of system memory (with 12.8 to 23.8 GB of memory per vCPU) for large-scale in-memory databases such as SAP HANA and online analytical processing (OLAP) workloads.
- **Shared-core machine types**: allocate a fixed amount of memory paired with a timeshared physical CPU core. These machine types provide a cost-effective option for lightweight microservices and development or test environments.

For more information about predefined machine types, see
[Predefined machine types](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt#predefined-types).

### Host memory versus accelerator memory

On [accelerator-optimized](https://docs.cloud.google.com/compute/docs/accelerator-optimized-machines.md.txt) and
other [TPU](https://docs.cloud.google.com/compute/docs/tpus/tpu-machines.md.txt) compute instances, memory is divided
between two distinct pools:

- **Host system memory (RAM)**: attached to the host CPUs (up to 3,968 GB of DDR5 memory on A4 instances or 960 GB of LPDDR5X memory on A4X Max bare metal instances). Host memory stores operating system processes, data preprocessing pipelines, model checkpoints, and datasets staged for transfer to accelerators.
- **Accelerator memory (HBM or GDDR)**: dedicated high-bandwidth memory (HBM) or graphics double data rate (GDDR) memory integrated directly onto the GPU or TPU package. Accelerator memory delivers terabytes per second of bandwidth to feed matrix and vector processing units during AI training and inference.

For more information about accelerator memory specifications, see
[Understand GPUs](https://docs.cloud.google.com/docs/compute-area/gpus.md.txt) and
[Understand TPUs](https://docs.cloud.google.com/docs/compute-area/tpus.md.txt).

## Memory optimization and NUMA

The latency and throughput of memory operations depend on the underlying DRAM
generation, memory channel architecture, and physical alignment between
processors and memory modules.

### Memory technologies and bandwidth

Compute Engine instances use different physical memory technologies
depending on the processor generation of the machine series:

- **DDR5 SDRAM** : available on most third-, fourth-, and fifth-generation [machine series](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt). DDR5 provides higher memory bandwidth per channel, higher DIMM density, and improved power efficiency compared to DDR4, accelerating memory-bandwidth-bound workloads such as scientific computing, in-memory databases, and vector search.
- **DDR4 SDRAM** : available on first- and second-generation [machine series](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt), and on the third-generation M3 machine series.
- **LPDDR5X memory**: available on NVIDIA Grace and Vera Arm-based machine series (A4X, A4X Max, and A5X), providing high-bandwidth, low-power memory tightly coupled to the CPU and GPU over NVIDIA NVLink-C2C.

### Non-uniform memory access (NUMA) versus uniform memory access (UMA)

Multi-socket and large multi-core servers organize physical memory using either
a [non-uniform memory access (NUMA)](https://wikipedia.org/wiki/Non-uniform_memory_access)
or a [uniform memory access (UMA)](https://wikipedia.org/wiki/Uniform_memory_access)
architecture:

- **NUMA architecture** : divides physical CPUs and memory into localized groups called *NUMA nodes* (or *NUMA domains* ). Each CPU socket or die cluster has its own local memory controller and directly attached DIMMs:
  - **Local memory access**: when a vCPU accesses memory located on its own NUMA node, data travels directly through the local memory controller with minimal latency and maximum bandwidth.
  - **Remote memory access**: when a vCPU accesses memory attached to a different NUMA node, the request must traverse an inter-socket interconnect (such as Intel Ultra Path Interconnect or AMD Infinity Fabric). Cross-node memory traffic increases access latency and can create interconnect contention under heavy load.
  - On performance-sensitive machine series (such as C4, C4D, C4N, C3, C3D, H4D, H3, Z4M, Z4D, Z3, M4N, X5, and X4), Compute Engine aligns VM vCPUs and memory directly with the host server's physical NUMA nodes and exposes virtual NUMA (vNUMA) topology to the guest operating system. This alignment lets NUMA-aware operating systems, databases, and hypervisors schedule threads and allocate memory within the same node.
- **UMA architecture**: provides uniform memory latency and bandwidth from any core to any memory location within a single memory domain. Arm-based machine series such as C4A, N4A (powered by Google Axion processors), and Tau T2A (powered by Ampere Altra processors) operate within a single UMA domain (1 NUMA node). UMA eliminates cross-socket memory penalties and simplifies application memory tuning.

To optimize performance on large multi-node instances, configure your database
engine or application runtime to bind worker threads and memory allocations to
local NUMA nodes (for example, by using `numactl` on Linux).

### Dynamic resource management and memory ballooning

Compute Engine uses hardware and hypervisor optimizations to manage
host memory allocation efficiently:

- **Dedicated host memory**: for N1, N2, N2D, Tau (T2A and T2D), and for C, M, X, H, Z, G, and A machine series, physical host memory is statically and exclusively allocated to your compute instance for its entire runtime.
- **Dynamic resource management** : on N4, N4D, and N4A VMs powered by Google [Titanium](https://cloud.google.com/titanium), [dynamic resource management](https://docs.cloud.google.com/compute/docs/dynamic-resource-management.md.txt) maps virtual RAM to physical host pages on demand when a guest-physical page is first accessed. Predictive VM placement, NUMA-affinity scheduling, and performance-aware live migration help prevent memory contention between VMs on the same host.
- **Virtio memory ballooning on E2 VMs** : E2 VMs use a [virtio memory balloon device](https://docs.cloud.google.com/compute/docs/dynamic-resource-management.md.txt#virtio_memory_balloon_device_with_e2_vms) to dynamically communicate unused guest memory pages to the host hypervisor. The host can reclaim free pages (balloon inflation) to allocate to other VMs and return pages when the guest workload demands them (balloon deflation). E2 is the only machine series that uses a memory balloon device.

## Memory security and monitoring

Consider the following memory security features, monitoring tools, and guest OS
behaviors when planning your deployment:

- **Memory encryption in use** : all Compute Engine VMs use infrastructure memory isolation. For workloads that process sensitive or regulated data, you can use [Confidential VM](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/confidential-vm-overview.md.txt) to encrypt data in RAM using hardware-based memory encryption technologies (Intel TDX, AMD SEV, or AMD SEV-SNP). Support depends on the specific machine type; see [Supported machine types](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/supported-configurations.md.txt#machine-types) for exact availability.
- **Guest memory metrics** : because guest memory management occurs inside the operating system, standard hypervisor metrics don't report guest OS memory usage (except on E2 VMs with the balloon driver enabled). To monitor active, free, cached, and swap memory inside your compute instances, install the [Ops Agent](https://docs.cloud.google.com/stackdriver/docs/solutions/agents/ops-agent.md.txt) to send memory telemetry to [Google Cloud Observability](https://docs.cloud.google.com/stackdriver/docs.md.txt).
- **Usable memory and out-of-memory (OOM) behavior** : guest OS utilities such as `free -m` on Linux typically report slightly less total RAM than the machine type's advertised capacity because firmware and the OS kernel reserve a small amount of memory at boot. Because Compute Engine doesn't automatically increase an instance's allocated memory, if a workload exhausts available RAM and any configured swap space, then the guest OS manages the condition (for example, the Linux OOM killer stops high-memory processes to recover memory).

## Customize memory limits

If predefined machine types don't match your workload's memory requirements,
then you can customize memory allocations or scale up to higher-capacity
machine series.

### Custom machine types

You can create a VM with a
[custom machine type](https://docs.cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type.md.txt)
on the [general-purpose](https://docs.cloud.google.com/compute/docs/general-purpose-machines.md.txt) N and E machine
series (N4, N4D, N4A, N2, N2D, N1, and E2, including E2 shared-core)
and on the accelerator-optimized G2 machine series. Custom machine types let
you independently select the number of vCPUs and the amount of memory:

- For N and E machine series, you can adjust memory in 256 MB (0.25 GB) increments within the standard per-vCPU memory range:
  - **N4 and N4A**: from 2 GB to 8 GB of memory per vCPU.
  - **N4D, N2, N2D, and E2**: from 0.5 GB to 8 GB of memory per vCPU.
  - **E2 shared-core** : `e2-micro` caps at 2 GB total, `e2-small` caps at 4 GB total, and `e2-medium` caps at 8 GB total.
  - **N1**: from 0.9 GB to 6.5 GB of memory per vCPU. Custom VMs with 1 or 2 vCPUs require at least 1 GB per vCPU (0.9 GB applies above 2 vCPUs).
- For G2 VMs, you can adjust memory in 1,024 MB (1 GB) increments within the supported range for the attached GPU count.

### Extended memory

If your workload needs more memory per vCPU than the standard custom machine
type maximum (8 GB per vCPU, or 6.5 GB per vCPU on N1), then you can enable
[extended memory](https://docs.cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type.md.txt#extendedmemory)
on N4, N4D, N4A, N2, N2D, and N1 custom machine types. Extended
memory lets you provision memory up to the maximum capacity of the machine
series, regardless of the vCPU count:

- **N2**: up to 864 GB of memory
- **N4D and N2D**: up to 768 GB of memory
- **N4**: up to 640 GB of memory
- **N1**: up to 624 GB of memory
- **N4A**: up to 512 GB of memory

Extended memory is well suited for databases (such as Microsoft SQL Server,
MongoDB, Redis, and Memcached) that require large in-memory caches but few
vCPUs. When you keep the vCPU count low and add extended memory, you avoid
paying per-core software licensing costs for unused vCPUs.

### Scale to high-memory and memory-optimized configurations

When you design for high-memory workloads, consider the following strategies:

- **Migrate to memory-optimized machine series** : if your workload requires more than 640 GB to 864 GB of memory or needs high memory-to-vCPU ratios with the lowest cost per GB of RAM, then use the [memory-optimized machine family](https://docs.cloud.google.com/compute/docs/memory-optimized-machines.md.txt) (M4, M4N, M3, M2, M1, X4, or X5), which scales from 31 GB on M4 and M4N VMs up to 48 TB on X5 bare metal instances.
- **Combine predefined shapes with visible core customization** : extended memory carries a pricing premium and doesn't qualify for resource-based committed use discounts (CUDs). If you use resource-based CUDs and need to limit vCPU count for software licensing, then it's often more cost-effective to select a larger predefined `highmem` machine type and [customize the number of visible CPU cores](https://docs.cloud.google.com/compute/docs/instances/customize-visible-cores.md.txt) than to use extended memory.

## Pricing considerations

When you budget for memory-intensive workloads, consider how
Compute Engine bills for memory and which discount options apply.

### Resource billing granularity

For most machine series, Compute Engine bills system memory (per GB)
and vCPUs as separate line items. Memory usage is billed in one-second
increments with a 1-minute minimum billing duration each time an instance
starts. For shared-core machine types (E2 and N1 shared-core), vCPUs and
memory are bundled into a single combined hourly rate.

Custom machine types include a 5% pricing premium over the on-demand and
committed use prices for equivalent predefined machine types. Any memory that you
provision above the standard per-vCPU maximum (by using `-ext` extended memory)
is billed at a separate, higher extended-memory rate.

For regional memory rates across all machine series, see the
[VM instance pricing](https://docs.cloud.google.com/compute/vm-instance-pricing) page.

### Cost optimization and discounts

You can reduce memory billing costs by using the following options:

- [**Committed use discounts (CUDs)**](https://docs.cloud.google.com/compute/docs/instances/committed-use-discounts-overview.md.txt): for predictable workloads, 1-year or 3-year commitments provide up to 55% to 70% off on-demand memory and vCPU prices:
  - **Resource-based CUDs**: apply to memory and vCPUs in a specific machine series and region (including custom machine type memory up to the standard per-vCPU limit, with a 5% custom premium). Extended memory doesn't qualify for resource-based CUDs.
  - **Compute flexible CUDs**: spend-based commitments that apply across multiple machine series and regions, and cover extended memory usage.
- [**Sustained use discounts (SUDs)**](https://docs.cloud.google.com/compute/docs/sustained-use-discounts.md.txt): automatically discount memory and vCPU usage on eligible machine series (N1, N2, N2D, C2, M1, and M2, including custom and extended memory) when instances run for more than 25% of a billing month, offering up to a 20% or 30% monthly discount depending on the series.
- [**Spot VMs**](https://docs.cloud.google.com/compute/docs/instances/spot.md.txt) and [**Flex-start VMs**](https://docs.cloud.google.com/compute/docs/instances/about-flex-start-vms.md.txt): provide lower prices than on-demand rates for memory and compute resources for fault-tolerant, batch, or flexible-duration workloads.
- [**Rightsizing recommendations**](https://docs.cloud.google.com/compute/docs/instances/apply-machine-type-recommendations-for-instances.md.txt): Compute Engine analyzes historical utilization metrics (enhanced by memory telemetry from the [Ops Agent](https://docs.cloud.google.com/stackdriver/docs/solutions/agents/ops-agent.md.txt)) to recommend switching between `standard`, `highcpu`, `highmem`, or custom machine types so you don't pay for unused memory.

## Machine families memory overview

The following list summarizes each Compute Engine machine family:

- **General-purpose** : balances price and performance for a wide range of workloads, with `standard`, `highcpu`, `highmem`, custom, and extended memory options.
- **Storage-optimized**: designed for workloads with lower core requirements and high local storage density.
- **Compute-optimized**: designed for high performance computing (HPC) and compute-intensive workloads that require high per-core performance on Compute Engine.
- **Network-optimized**: designed for I/O-intensive workloads that require high network bandwidth, packet processing performance, and block storage throughput and IOPS per vCPU.
- **Memory-optimized**: designed for memory-intensive workloads, offering higher memory-to-vCPU ratios than other machine families.
- **Accelerator-optimized**: designed for massively parallelized machine learning (ML) and HPC workloads that require GPUs or TPUs.

For complete specifications across all machine series, see the
[Machine families resource and comparison guide](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt).

## What's next

- Compare vCPU and memory specifications in the [Machine families resource and comparison guide](https://docs.cloud.google.com/compute/docs/machine-resource.md.txt).
- Explore high-capacity configurations in the [Memory-optimized machine family](https://docs.cloud.google.com/compute/docs/memory-optimized-machines.md.txt) guide.
- Learn how to [Create a VM with a custom machine type](https://docs.cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type.md.txt) or add extended memory.
- Learn how processor architectures and threading interact with memory in [Understand vCPUs](https://docs.cloud.google.com/docs/compute-area/vcpus.md.txt).
- Apply [machine type recommendations](https://docs.cloud.google.com/compute/docs/instances/apply-machine-type-recommendations-for-instances.md.txt) to rightsize instance memory and vCPU utilization.