Skip to content

Set DART_VM_OPTIONS for image proxy to adjust GC - #9557

Closed
sigurdm wants to merge 2 commits into
dart-lang:masterfrom
sigurdm:image-proxy-gc-env
Closed

Set DART_VM_OPTIONS for image proxy to adjust GC#9557
sigurdm wants to merge 2 commits into
dart-lang:masterfrom
sigurdm:image-proxy-gc-env

Conversation

@sigurdm

@sigurdm sigurdm commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Configure DART_VM_OPTIONS="--old_gen_heap_size=768" for the image proxy server in both the Dockerfile and Cloud Build deployment step.

  • --old_gen_heap_size=768: caps old generation heap (75% of the 1 GiB container memory limit) to trigger garbage collection before reaching container memory boundaries, leaving ~256 MB for new-gen heap, thread stacks, TLS/socket buffers, and runtime overhead.

Improves the situation on #9554 (but we should also increase memory).

Configure `--old_gen_heap_size=768` to cap old generation heap size
and trigger GC compaction before container memory limits, and
`--dontneed_on_sweep` to release freed heap pages back to the host kernel
via madvise(MADV_DONTNEED).
@sigurdm
sigurdm requested a review from jonasfj August 27, 2026 13:35

@jonasfj jonasfj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really a good idea?

@sigurdm

sigurdm commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, I would think so - nice to prevent OOM by triggering GC before it grows out of your available memory. but of course I don't really knows how well it works.

@mkustermann might be able to give guidance...

@sigurdm

sigurdm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing for now.

As detailed in dart-lang/sdk#29786 (comment), setting --old_gen_heap_size acts as a strict allocation ceiling rather than a soft target. In a 1 GiB container, it risks premature OutOfMemoryErrors and GC thrashing during temporary bursts that the container could otherwise absorb.

The Cloud Run container memory for image proxy has already been doubled to 1 GiB in cl/973847545, which provides ample headroom for concurrent requests without needing a manual VM heap cap.

@sigurdm sigurdm closed this Sep 1, 2026
@mkustermann

Copy link
Copy Markdown
Member

/cc our GC expert: @rmacnak-google

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.

3 participants