Skip to content

v10.0.0: resident memory grows with bytes uploaded and is never released (~1.4–2.8 MB per GB) #318

Open

Description

@connorwang

Version: ghcr.io/falcondev-oss/github-actions-cache-server:10.0.0 (multi-arch index
sha256:05c4d9e7169f525f2b74d412c4a081aeec5446a017ec88bae668e63ebfb16aa9), linux/amd64.
Configuration: STORAGE_DRIVER=filesystem, DB_DRIVER=sqlite, CACHE_MAX_SIZE_BYTES=256 GiB,
CACHE_CLEANUP_OLDER_THAN_DAYS=7, token validation on. Kubernetes (k3s), 1 replica.

What happens

The server's anonymous memory grows in proportion to the bytes clients upload, and it does not
come back down when the server is idle. At a 1 GiB container limit, the kernel OOM-killed it twice
in four days.

Period (2026) Uploaded Anonymous memory
Nov 7 → Nov 9 ~330 GB 60 MB → 944 MB (OOM-killed)
Nov 9 → Nov 13 ~220 GB 220 MB → 832 MB (OOM-killed)

That is about 2.8 MB per GB uploaded. Uploads came from actions/cache v4 and BuildKit's
type=gha cache, 25–224 GB a day.

The image runs mimalloc with MIMALLOC_PURGE_DELAY=0, so freed pages should go back to the OS
promptly. The memory appears to be live, not held by the allocator.

Reproduction

Run the same image in Docker with the filesystem driver and SQLite on a volume throttled to
40 MB/s (--device-write-bps). Each round uploads and then restores 9.4 GiB of entries. Idle
anonymous memory after rounds 1–4:

Round Idle anon after round
1 157 MB
2 161 MB
3 180 MB
4 209 MB

That is about 1.4 MB per GiB retained. Upload errors under the throttle varied by round (1, 22
and 3).

With the same load on an unthrottled disk, memory levelled off at about 135–150 MB. The leak
therefore seems tied to slow storage, and possibly to failed or aborted uploads. In production,
the volume is a loop-mounted image on an HDD mirror, and the server's log shows slow SQLite
statements and 3–4 s connection waits.

Expected

Idle memory returns to a steady level after uploads finish, whatever the storage speed and
whether or not uploads fail.

Possibly related: #274 (closed; upload and download stream backpressure in v9.7/v9.8). The
v10.0.1 release notes list only a download-corruption fix, so this does not appear to be
addressed there.

Data available on request

  • /proc/<pid>/smaps sampled every 15 min. It splits anonymous memory into the mimalloc arena and
    other anonymous mappings, which may show whether the growth is in the Rust heap or in SQLite's
    allocations.
  • The memory cgroup's memory.stat at each kill.
  • The repro script.

Workaround we run

A sidecar restarts the Deployment once resident memory passes half the limit, at a quiet hour,
when no transfer is in flight.

Activity

  1. LouisHaftmann commented on Nov 23, 2026

    @LouisHaftmann
    Collaborator

    Thanks for the detailed report. I tried to reproduce this with the same setup (filesystem driver, SQLite, writes throttled to 40 MB/s with --device-write-bps), but I couldn't get memory to grow without limit.

    Setup Uploaded Idle anonymous memory
    Fast disk, large entries 24 GiB levels off at ~95–110 MB
    Fast disk, 2000 × 1 MiB entries per round 60 GiB rises to ~120 MB, then stays there
    40 MB/s throttle, 10.0.1 image 50 GiB 155–192 MB, no upward trend
    Same build with the system allocator instead of mimalloc 50 GiB 42 → 69 MB
    Eviction active (4 GiB budget, cleanup jobs on) 40 GiB flat

    The memory the server actually uses stays around 40–70 MB. mimalloc keeps another 100–130 MB on top of that, but in my runs that extra did not keep growing. Aborted uploads, many small entries, idle gaps between rounds and capacity-based eviction made no difference.

    The throttled runs did reproduce the slow SQLite statements and connection waits from your logs. They also showed what caused your upload errors: uploads arrive faster than the disk writes them out, and every SQLite commit waits behind that backlog until the connection pool times out with a 500. #319 fixes that. The filesystem driver now writes each part to disk before confirming it, so uploads run at disk speed and the backlog stays bounded. This should also reduce the 3–4 s connection waits you see.

    I don't have an explanation for the 944 MB yet. Your setup does a few things mine didn't: token validation is on, it runs for days, the traffic is real BuildKit traffic, and the server runs under a 1 GiB memory limit. Could you share:

    1. The /proc/<pid>/smaps samples, especially one near the start and one shortly before an OOM kill. They show whether the growth is in the mimalloc arena or in other anonymous mappings (for example SQLite's allocations).
    2. The memory.stat from one of the kills.
    3. Your repro script.
    4. Whether MIMALLOC_PURGE_DELAY and MIMALLOC_ALLOW_THP are still set in the running container. They come from the image, so a Deployment that overrides the environment could drop them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions