Skip to content

ContainerService: Add minimum memory amount validation#1208

Merged
dcantah merged 1 commit intoapple:mainfrom
dcantah:mem-minimum
Feb 18, 2026
Merged

ContainerService: Add minimum memory amount validation#1208
dcantah merged 1 commit intoapple:mainfrom
dcantah:mem-minimum

Conversation

@dcantah
Copy link
Member

@dcantah dcantah commented Feb 13, 2026

Closes #1202

Today it's possible to pass a memory amount that very easily will cause the container's VM to not be able to boot. We should protect against this to avoid weird hangs/error messages. I could be convinced that a limit should be in Containerization as well, but I think having one in the daemon is a decent idea regardless.

Today it's possible to pass a memory amount that very easily will
cause the container's VM to not be able to boot. We should protect
against this to avoid weird hangs/error messages. I could be convinced
that a limit should be in Containerization as well, but I think
having one in the daemon is a decent idea regardless.
Peyton-Spencer added a commit to omniaura/nanoclaw that referenced this pull request Feb 15, 2026
Two issues caused containers to hang indefinitely:

1. Apple Container's `--memory` flag treats bare numbers as bytes, not
   megabytes. `--memory 1024` = 1024 bytes, causing the VM to never boot.
   Fix: use proper suffix (`--memory 4G`).
   Ref: apple/container#1202
   Ref: apple/container#1208

2. tsgo (TypeScript native compiler) has no default memory ceiling — Go
   doesn't auto-detect container memory limits, so tsgo allocates unbounded
   memory until the VM hangs under memory pressure.
   Fix: set GOMEMLIMIT=3GiB in entrypoint.
   Ref: microsoft/typescript-go#2125

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Peyton-Spencer added a commit to omniaura/nanoclaw that referenced this pull request Feb 15, 2026
* fix: resolve container OOM hangs from tsgo and --memory flag

Two issues caused containers to hang indefinitely:

1. Apple Container's `--memory` flag treats bare numbers as bytes, not
   megabytes. `--memory 1024` = 1024 bytes, causing the VM to never boot.
   Fix: use proper suffix (`--memory 4G`).
   Ref: apple/container#1202
   Ref: apple/container#1208

2. tsgo (TypeScript native compiler) has no default memory ceiling — Go
   doesn't auto-detect container memory limits, so tsgo allocates unbounded
   memory until the VM hangs under memory pressure.
   Fix: set GOMEMLIMIT=3GiB in entrypoint.
   Ref: microsoft/typescript-go#2125

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* make container memory configurable via CONTAINER_MEMORY env var

Default 4G, configurable in .env. GOMEMLIMIT auto-derives from
actual VM memory (75%) so it scales with any CONTAINER_MEMORY value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@dcantah dcantah merged commit dfac83d into apple:main Feb 18, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--memory should error on amounts that cause the VM for a container to not boot

3 participants

Comments