# How We Stabilized a Bazel CI Runner by Fixing Resource Limits and Container Cleanup

DevFeed: [How We Stabilized a Bazel CI Runner by Fixing Resource Limits and Container Cleanup](<https://devfeed.tech/articles/how-we-stabilized-a-bazel-ci-runner-by-fixing-resource-limits-and-container-cleanup-114855.md>)

Original publisher: [Read original article](<https://hackernoon.com/how-we-stabilized-a-bazel-ci-runner-by-fixing-resource-limits-and-container-cleanup?source=rss>)

Author: Daniil Romashov

Published: 2026-11-03T15:21:51Z

Content type: article

Language: en

Sources: [HackerNoon](<https://devfeed.tech/sources/hackernoon.md>)

Topics: [bazel](<https://devfeed.tech/topics/bazel.md>), [cgroups](<https://devfeed.tech/topics/cgroups.md>), [scheduling](<https://devfeed.tech/topics/scheduling.md>), [Integration testing](<https://devfeed.tech/topics/integration-testing.md>)

Tags: [bazel](<https://devfeed.tech/tags/bazel.md>), [builds](<https://devfeed.tech/tags/builds.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [cache](<https://devfeed.tech/tags/cache.md>), [capacity](<https://devfeed.tech/tags/capacity.md>), [cfs](<https://devfeed.tech/tags/cfs.md>), [cgroups](<https://devfeed.tech/tags/cgroups.md>), [ci](<https://devfeed.tech/tags/ci.md>), [ci-cd](<https://devfeed.tech/tags/ci-cd.md>), [cleanup](<https://devfeed.tech/tags/cleanup.md>), [code-review](<https://devfeed.tech/tags/code-review.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [container](<https://devfeed.tech/tags/container.md>), [container-cleanup](<https://devfeed.tech/tags/container-cleanup.md>), [container-images](<https://devfeed.tech/tags/container-images.md>), [containers](<https://devfeed.tech/tags/containers.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [cpus](<https://devfeed.tech/tags/cpus.md>), [docker](<https://devfeed.tech/tags/docker.md>), [gitlab-runner](<https://devfeed.tech/tags/gitlab-runner.md>), [limits](<https://devfeed.tech/tags/limits.md>), [monorepo](<https://devfeed.tech/tags/monorepo.md>), [oom](<https://devfeed.tech/tags/oom.md>), [oom-killer](<https://devfeed.tech/tags/oom-killer.md>), [resource](<https://devfeed.tech/tags/resource.md>), [runner](<https://devfeed.tech/tags/runner.md>)

## AI overview

Bazel CI jobs were being OOM-killed because a runner with 6 cores and 62 GiB of memory had no per-job cgroup limits, while jobs acted on stale configuration promising 5 CPUs and 24 GiB each. After three days of tuning, the runner stabilized at five jobs with a hard 11 GiB memory cap per job; Bazel's local resource estimate was set below that cap, using measured 6.68 GiB RSS rather than an 11.37 GiB working set that included reclaimable page cache. Hard CPU quotas caused heavy throttling, so CPU allocation was made fair while the memory cap remained strict. The team also moved linting and review tasks to a lighter runner. Separately, integration-test helper containers launched through the Docker SDK outlived canceled CI jobs because cleanup in finally blocks was skipped and the containers lacked the labels used by garbage collection. Adding the Testcontainers label at each launch site made them eligible for cleanup. The account emphasizes verifying runner capacity and labeling all containers; it describes one environment and does not establish a universal configuration.

## Source excerpt

Bazel builds kept getting OOM-killed on a CI runner whose config promised 25 CPUs it did not have. How hard cgroup caps and three days of retuning settled the m