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

# Runtime memory caps

> StackShift sets a memory cap for your runtime on new deploys, so the app stays under its limit instead of being killed.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Know which caps StackShift sets, see them in Variables, and override or turn them off.

## Prerequisites

* A project with a memory limit.

## Workflow

**Step 1**

Open the project and choose Variables.

**Step 2**

Find the variable marked set by StackShift.

**Step 3**

To use your own value, edit it and save. It becomes yours and StackShift stops managing it.

**Step 4**

To turn caps off for the project, delete the variable.

**Step 5**

Redeploy to apply a change.

## On by default

Caps are on for new deploys. They show in Variables as plain variables marked set by StackShift. StackShift never overrides a value you set yourself.

## Values

* Go: GOMEMLIMIT at 90 percent of the limit.
* Node.js: NODE\_OPTIONS=--max-old-space-size at 75 percent of the limit. It also adds --heapsnapshot-signal=SIGUSR2 --diagnostic-dir=/tmp so memory snapshots work.
* Java: JAVA\_TOOL\_OPTIONS=-XX:MaxRAMPercentage=75.
* Python with gunicorn or uvicorn, and Ruby with Puma: WEB\_CONCURRENCY, the number of workers.
* Laravel Octane: OCTANE\_WORKERS.
* PHP-FPM: PHP\_FPM\_MAX\_CHILDREN.

## Worker counts

Worker counts are worked out from the limit divided by the memory one worker was measured to use. They are between 1 and 32. They are not set until one worker has been measured, and not when your start command already passes -w or --workers.

For PHP-FPM, use the variable in your pool configuration.

```ini PHP-FPM pool theme={null}
pm.max_children = ${PHP_FPM_MAX_CHILDREN}
```

## Related finding

If a cap is missing, What to improve shows a No runtime cap finding with an Apply button that turns caps on.

## Expected result

> [!TIP]
>
> Your app is capped below its limit, or uses the value you chose.

## Related guides

> [card] [Project environment, domains, and previews](https://docs.stackshift.cloud/projects/environment-domains-and-previews.md)
>
> Configure the project surfaces that most often decide whether a deployment works after it builds, including runtime shape, domains, previews, and storage.

> [card] [What to improve](https://docs.stackshift.cloud/performance/what-to-improve.md)
>
> A ranked list of findings for the project. Each says what is wrong, shows the evidence, says what fixing it is worth and gives the steps.

> [card] [Change memory](https://docs.stackshift.cloud/performance/change-memory.md)
>
> Pick a memory size for a service. StackShift marks the size that fits what it measured and shows the price difference.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.