# CLAUDE_CODE_TOOL_MEMORY_LIMIT

> It caps how much memory Claude's commands can use.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** CLAUDE_CODE_TOOL_MEMORY_LIMIT environment variable

## Think of it like

It is like a big game on a small table. It may only use part of it.

## Definition

CLAUDE_CODE_TOOL_MEMORY_LIMIT caps the memory that Bash and PowerShell commands can use, on Linux and WSL. Write a size such as 4G, or a plain number of bytes. Set 0 or off to turn the cap off. A changed value takes effect the next time you start claude. It needs version 2.1.233 or later.

## Example

Jack's build once ate all his memory and froze the laptop. He sets a 4G cap, so a runaway command is stopped first.

## Example code

```bash
export CLAUDE_CODE_TOOL_MEMORY_LIMIT=4G
claude
```

Keep each command under 4 GB.

## Why it matters

One command that eats all the memory can freeze the whole machine.

## Common mistake

Expecting it to work on a Mac. It only works on Linux and WSL.

## Three principles

- **Size like 4G.** Or bytes.
- **0 or off.** No cap.
- **Linux and WSL.** Next start.

## Related terms

- [Bash Tool](https://learn.benibix.com/term/ai/bash-tool)
- [BASH_MAX_OUTPUT_LENGTH](https://learn.benibix.com/term/ai/bash-max-output-length-variable)

---

Source: https://learn.benibix.com/term/ai/claude-code-tool-memory-limit-variable
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
