Skip to content

Adjust overcommit and max_map_count vm defaults in guest VMs - #2055

Merged
jglogan merged 1 commit into
apple:mainfrom
adityabagchi24:fixmemory
Aug 2, 2026
Merged

jglogan merged 1 commit into
apple:mainfrom
adityabagchi24:fixmemory

Conversation

@adityabagchi24

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Description

Each container runs in its own guest VM sized to --memory with no swap, so the guest kernel's stock vm sysctl defaults are hit far too easily:

  • vm.overcommit_memory=0 (heuristic overcommit) rejects an oversized mmap() upfront whenever the reservation exceeds the small, swap-less VM's free RAM — even if the memory is never touched — returning ENOMEM.
  • vm.max_map_count=65530 caps per-process mapping count, which mapping-heavy applications (e.g. Elasticsearch, many JVMs) legitimately exceed.

Fixes #2053

Motivation and Context

These stock defaults cause common oversubscribed-mmap and many-mapping workloads to fail inside a container even though they work on a typical host. This PR applies container-friendly defaults at container start so these workloads succeed, while actual memory usage remains enforced by the container's existing --memory limit (via cgroup memory limit and the OOM killer).

Implementation

  • Sources/Services/RuntimeLinux/Server/RuntimeService.swift: set vm.overcommit_memory=1 and vm.max_map_count=262144 as defaults when configuring a container's guest sysctls.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 24.33%
Integration 66.2%
Combined 75.59%

@jglogan jglogan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@adityabagchi24 Thanks for taking care of this!

@jglogan
jglogan merged commit a58c5fe into apple:main Aug 2, 2026
4 checks passed
@adityabagchi24

Copy link
Copy Markdown
Contributor Author

@jglogan Thank you so much for merging my PR.

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.

[Request]: Set container-friendly defaults for vm.overcommit_memory and vm.max_map_count in the guest VM

2 participants