Skip to content

Mac: guest memory in files by default when the pool is over 2/5 of the Mac's memory (Mario Kart World on 18 GB: 12.3 GB and climbing → 5.5 GB flat) - #2606

Open
lucasmartin042009-sudo wants to merge 1 commit into
seedds:mainfrom
lucasmartin042009-sudo:mac-guest-file-default

Conversation

@lucasmartin042009-sudo

Copy link
Copy Markdown

What and why

On a Mac, a game whose memory pool is a large share of the machine's memory fills the footprint over a session even though it never leaks: every page the game touches stays charged after the game's own allocator frees it, compressed or swapped but counted in full. Mario Kart World (9 GB pool) on an 18 GB M3 Pro at 3 players went from 8.0 to 12.3 GB in 21 minutes and was still climbing, and a launcher-side memory cap at 12-14 GB stopped play after 12-20 minutes. Measured with DM_MEMSTAT, 69 % of the growth was the guest; Metal's own memory was flat at about 4.5 GB from minute 12, and every texture the host kept still belonged to a live NVN object in a live pool, so this is not a host leak.

The guest-in-files mode already handles this (DM_GUEST_FILE=1), but on the Mac it is only on when asked. This change turns it on by default when the pool is more than 2/5 of the Mac's memory (hw.memsize): Mario Kart World on 16 and 18 GB Macs, not on 24 GB and up, and no Switch 1 game on a 16 GB Mac. DM_GUEST_FILE=0 still keeps it off and 1 forces it on; the [mem] guest memory line now says which on the Mac too. The disk rule is unchanged: with less than 2 + 8 GB free the guest stays anonymous with a [RED] line.

Entry updated: docs/reference/memory.md, "iOS ends the app once the guest's touched pages reach its memory limit"; switch row in docs/env_switches.tsv.

Checked

  • Tests: make -C dm/host/tests memory memory-file : the six runs pass, the default ones anonymous ("guest files 0") and the forced ones in 1, 65 and 1,013 files. New asserts in t_svc_memory.c file_rule for 16, 18 and 24 GB Macs. The test profile's pool is 16 MB, so the default stays anonymous on any CI runner.
  • Games run: Mario Kart World 1.0.0 (0400C3F00006E000), 3 players, 1080p window, scripted Grand Prix races for 21 minutes each, with the switch forced: on a local tree at 47607fe (11 Nov), not on this commit. The mechanism itself is unchanged here; only the default moves.
21 min, 3 players Footprint Guest charged Frames over 100 ms (over 250) Frame / GPU p50 Disk
anonymous 8.0 → 12.3 GB, climbing 3.8 → 6.1 GB 87 (48) 33.3 / 23.1 ms —
in files 4.4 → 5.5 GB, flat from minute 15 0 40 (20) 33.3 / 23.0 ms up to 5.4 GB, 11 GB written

No crash and no [RED] line in either run; the 3 players and the game's 30 fps mode were the same in both.

  • Devices and OS: MacBook Pro M3 Pro, 18 GB, macOS 27.2.1.
  • Not checked: other games with large pools, Macs with 16 or 24 GB, the GPU hang reported for punching on an M1 Pro (none seen here in 42 minutes of play with punching on).

Docs

  • The finding is in its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

… more than 2/5 of the Mac's memory: Mario Kart World (9 GB pool) on an 18 GB M3 Pro at 3 players went 8.0 → 12.3 GB in 21 minutes and still climbing, its touched pages charged after the game freed them, and held 5.5 GB in files with half the frames over 100 ms

The footprint growth was the guest (3.8 → 6.1 GB charged, 4.6 GB of it compressed or swapped), not the host: Metal's own memory was flat at about 4.5 GB from minute 12, and every texture the host kept belonged to a live NVN object in a live pool. The guest-in-files mode already handles that, but on the Mac it was on only when asked. guest_file_mac_room gives the Mac a room of 2/5 of hw.memsize for guest_file_wanted, the rule iOS uses with its memory limit: Mario Kart World on 16 and 18 GB Macs, not on 24 GB; a Switch 1 game's pool never on 16 GB. DM_GUEST_FILE=0 and 1 work as before, and the [mem] guest memory line now gives the decision on the Mac too. Same frame and GPU medians (33.3 / 23.0 ms), 87 → 40 frames over 100 ms, up to 5.4 GB on disk and 11 GB written in 21 minutes (switch forced on a 47607fe tree).

Checked: make -C dm/host/tests memory memory-file (six runs pass; new file_rule asserts for 16, 18 and 24 GB Macs; the test profile's 16 MB pool stays anonymous by default).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) docs Documentation labels Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation host The Horizon host: SVCs, services, threads, memory (dm/host)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant