> ## Documentation Index
> Fetch the complete documentation index at: https://novita.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory

The `sandbox hotplug-memory` command dynamically adjusts the memory of a running sandbox without restarting it. This is useful when a workload needs more memory than initially provisioned, or when you want to release extra memory once it is no longer needed.

<Warning>
  Memory hotplug requires a **hotplug-enabled template**. Sandboxes created from templates without hotplug support cannot adjust memory at runtime.
</Warning>

## Prerequisites

* Set the `NOVITA_API_KEY` environment variable.
* A running sandbox created from a hotplug-enabled template.

## Usage

```bash CLI icon="terminal" theme={"system"}
novita-sandbox-cli sandbox hotplug-memory <sandboxID> <size-mib>
```

The command has the alias `hp`.

```bash CLI icon="terminal" theme={"system"}
# Set the hotplugged memory of the sandbox to 2048 MiB
novita-sandbox-cli sandbox hotplug-memory sbx-123 2048

# Using the alias
novita-sandbox-cli sandbox hp sbx-123 2048
```

## Arguments

| Argument      | Description                                                                                         |
| ------------- | --------------------------------------------------------------------------------------------------- |
| `<sandboxID>` | ID of the running sandbox to adjust.                                                                |
| `<size-mib>`  | New **total** hotplugged memory size in MiB — not a delta. Use `0` to unplug all hotplugged memory. |

<Warning>
  The size represents the new total plugged memory, not an increment on top of the current value. It must be a multiple of the virtio-mem block size (2 MiB).
</Warning>

## Unplug all hotplugged memory

Pass `0` to remove all previously hotplugged memory, returning the sandbox to its base allocation.

```bash CLI icon="terminal" theme={"system"}
novita-sandbox-cli sandbox hotplug-memory sbx-123 0
```

## Output and errors

* On success, the CLI prints a confirmation such as `Memory hotplug complete: sandbox sbx-123 set to 2048 MiB`.
* If the sandbox ID is not found, the CLI prints `Sandbox sbx-123 wasn't found` and exits with code `1`.
* Any other error is printed and the CLI exits with code `1`.
