Repository navigation
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
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=0still keeps it off and1forces it on; the[mem] guest memoryline 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 indocs/env_switches.tsv.Checked
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 int_svc_memory.cfile_rulefor 16, 18 and 24 GB Macs. The test profile's pool is 16 MB, so the default stays anonymous on any CI runner.No crash and no
[RED]line in either run; the 3 players and the game's 30 fps mode were the same in both.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run🤖 Generated with Claude Code