gitlab runner内存相关配置shm_size、memory、memory_swap

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