# gitlab runner内存相关配置shm\_size、memory、memory\_swap

**URL:** <https://forum.beginner.center/t/topic/2625>\
**Category:** 🛠工具与编程\
**Tags:** gitlab\
**Created:** [January 30, 2026, 6:59am UTC](https://forum.beginner.center/t/topic/2625 "2026-01-30T06:59:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![doggie](https://forum.beginner.center/user_avatar/forum.beginner.center/doggie/32/550_2.png) [@doggie](https://forum.beginner.center/u/doggie)\
**Post date:** [January 30, 2026, 6:59am UTC](https://forum.beginner.center/t/topic/2625/1 "2026-01-30T06:59:23Z")

</div>

#### `memory` (Physical Memory Limit)

This is the maximum total RAM that the container can use.

- **Configuration** : Set in `config.toml` via `memory = "4g"`.
- **If not set** : Docker containers have no memory limit by default. If your build job consumes all 16 GB of the host’s RAM, the host itself may crash.
- **Your case** : The previous error `Job failed: exit code 1`, accompanied by `Killed` in the logs, strongly suggests hitting a physical memory bottleneck—either the host ran out of memory or a memory limit was previously configured.

#### `shm_size` (Shared Memory Size)

This is a special **in-memory filesystem**. Although it resides in RAM, its size is restricted separately.

- **Configuration** : Set in `config.toml` via `shm_size` (value in bytes).
- **Why is the default 64 MB insufficient?**
  - **Browser testing** : If you run Puppeteer, Playwright, or Selenium (launching headless Chrome) in CI, Chrome heavily relies on `/dev/shm` for page rendering. 64 MB fills up instantly, causing browser crashes (errors typically show `Page crashed`, not OOM).
  - **High-concurrency builds** : Some build tools (e.g., highly concurrent webpack/vite bundling) may leverage shared memory to accelerate inter-process data transfer.

- **Recommendation** : For modern frontend projects, allocate at least **1 GB** (`1073741824`) or **2 GB**.

# Reference

> **[Advanced configuration | GitLab Docs](https://docs.gitlab.com/runner/configuration/advanced-configuration/)**
>
> GitLab product documentation.
