Metal runs out of GPU memory on 16 GB Macs, then the game crashes #8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T07:35:22Z.
Reported in #7 (M4 MacBook Air, 16 GB, macOS 27.2.1, commit
15433a9).What happens
Insufficient Memory (kIOGPUCommandBufferCallbackErrorOutOfMemory).image+0x55e56f8.Likely cause
The game sizes its pools for the Xbox's memory budget. On a 16 GB Mac, with macOS and other apps also running, the GPU allocations don't fit. We haven't seen this on machines with more RAM.
Ideas
MTLDevice.recommendedMaxWorkingSetSize).Start here:
crates/victory-gpu/src/native/glue.rs(mirroring) and the native host's pool mapping.Testers with 8, 16 and 24 GB Macs: a log from a run on current
mainhelps a lot.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T08:57:08Z.
Opened https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/12 to automatically default
tools/macos/run-native.shto--console series-s(7.6 GiB instead of Series X's 13.5 GiB) on Macs with<= 16 GBRAM, matching the 13.5 GB crash report figure here (with--console series-xavailable as an override).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:53:08Z.
Status update: #12 has been merged to
main, sotools/macos/run-native.shnow automatically defaults to--console series-s(7.6 GiB budget instead of Series X's 13.5 GiB) on Macs with<= 16 GBRAM.Keeping this issue open until a 16 GB Mac tester confirms whether
--console series-savoidskIOGPUCommandBufferCallbackErrorOutOfMemory(and whether GPU pool capping / lazy backing is still needed).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:28:37Z.
Update from two new 16 GB tester reports (#66 on M1 Pro, #68 on M4): both ran with
--console series-sand got past the earlier 22 s menu OOM into prologue loading / intro audio (frames 1664–2048+), but both still hit 20kIOGPUCommandBufferCallbackErrorOutOfMemoryerrors once prologue/world assets load.So
--console series-shelps get through setup/menus, and GPU pool capping / lazy backing is still needed for 16 GB Macs past that point.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T15:56:49Z.
Status: 16 GB Macs on --console series-s get past the menus but still hit kIOGPUCommandBufferCallbackErrorOutOfMemory once prologue assets load (reports #7, #66, #68, now closed as duplicates of this). PR #76 (residency per encoder, #79) may reduce the pressure; GPU pool capping or lazy backing is still needed. Needed: #76 updated, then a retest on 16 GB.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T22:52:59Z.
Update: the heap residency set is on main (
3009640b), and since0133b82ereleased textures leave it. It's on by default on 32 GB and up. 16–24 GB testers: please tryVICTORY_METAL_RESIDENCY_SETS=heapon current main and report theheap_set_mblines and any command-buffer errors.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by electrifie on 2026-11-27T08:24:20Z.
16 GB Series S run out of GPU memory at the first load after the menus: memory timeline and texture uploads
Setup: Mac mini M4, 16 GB, macOS 27.0.1. Metal Shader Converter 4.0.3. Commit
2a3b03dplus PR #260 (without #260 the window stays black on this commit). Series S (the 16 GB default), windowed, default residency (useResource per encoder). The log reportstitle_memory_mib=7776 recommended_working_set_mib=12124. Game files are on an external USB drive. Most other apps were closed.What happens: boot movie, start screen and setup screens run at 18–30 fps. At the first load after them, frames stop and Metal fails command buffers with
kIOGPUCommandBufferCallbackErrorOutOfMemory. The failing buffers are ordinary work (fills, a few compute dispatches, render passes of 9–10 draws); no one command stands out. There is no unhandled exception: the game sits on or near the stalled frame until the run is stopped.Two runs:
VICTORY_TRACE_TEXTURE_SYNC=1 VICTORY_TRACE_GPU_FAILS=1The second run reached the load earlier, apparently because of a warm shader cache.
Memory over time (traced run). Footprint is top's MEM (Activity Monitor's Memory column), sampled every 2 s:
Host texture uploads, same run (
texture sync in the last 1.0 s, summed):During the load the host makes about 13,000 new textures and uploads about 7 GB while the footprint grows about 7.6 GB. That fits host texture copies as the cause (the roadmap's suspect, #110).
Caveats:
A per-second count of live host texture bytes in the log would settle it. A sampler for footprint, pressure and swap per run (a small shell script next to
run-native.sh) is available as a PR if useful.Logs and
memory.tsvfrom both runs are attached.issue-8-attachments.zip
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T09:41:45Z.
A byte budget on host texture copies is up as draft PR #301 (issue #294). It follows on from @electrifie's run above, where the host made ~13,000 texture copies during the first load while the footprint grew ~7.6 GB. The budget is Metal's recommended working set less the title's memory: 12124 − 7776 = 4348 MiB on that M4 with Series S, never less than 1536 MiB. Past the budget, it gives up the least recently used copies that nothing uses: no heap entry shows them, no recorded or submitted work holds them, and they aren't render targets or GPU-written. It does not touch what the heap residency sets hold, so it can be combined with
VICTORY_METAL_RESIDENCY_SETS=heap.It may free little. #79 suggests most texture bytes are shown by heap entries, and those are never given up. The new trace line answers that from a 16 GB run, which is why I'm asking.
16 GB and 24 GB testers (@electrifie, and anyone from #79 or #110 with an 18 or 24 GB Mac), a run would help:
Then please post:
git rev-parse --short HEAD, the Mac and its memory, and the console profile;native host: Metalline (it now hastexture_budget_mib=);grep "host texture copies:" runs/<date>/victory.log, especially the lines around the first load after the menus. Each line gives the MiB of copies, the budget, how much heap entries show, how much could be given up, how much was given up and how many came back;kIOGPUCommandBufferCallbackErrorOutOfMemorylines there are, and the frame where frames stop, compared with your last run on main.If you have time, a second run with
VICTORY_METAL_TEXTURE_BUDGET_MB=0(no budget, otherwise the same) gives a clean comparison. On 24 GB, a run withVICTORY_METAL_RESIDENCY_SETS=heapadded shows the two together.If the copies turn out to be mostly "shown by heap entries", this PR won't be enough on its own. That would point at the levers in #79 (one copy instead of two, fewer top mips).
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by daidalos4 on 2026-11-27T11:12:42Z.
VICTORY_METAL_RESIDENCY_SETS=heapon a 16 GB Mac, as asked above.Setup: MacBook Pro M1 (MacBookPro17,1), 16 GB, macOS 27.0.1,
--console series-s, main atc1b95875plus the read cache from #101. Startup line:title_memory_mib=7776 recommended_working_set_mib=12124.heap_set_mbover the run (story load after the engagement screen, Enter viaVICTORY_KEYS):The set jumps by ~5.8 GB in 9 seconds around frame 5200, then creeps up. The first
kIOGPUCommandBufferCallbackErrorOutOfMemorycomes at +7:28, at 10651 MB, with 19 failed command buffers in the next 90 s. The loading-screen art draws correctly until then.The same load without the flag (default per-encoder residency) also hit
OutOfMemoryabout 15 min in, then an access violation in the title atimage+0x55e56f8.Happy to rerun with #301 or any other switch.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ItsMariusBC on 2026-11-27T11:42:40Z.
The 24 GB data point asked for above:
VICTORY_METAL_RESIDENCY_SETS=heapagainst the default, on current main.Apple M5 Pro, 24 GB, macOS 27.2.1, main
c1b9587, Series S, windowed, game files on an external USB disk. The log saystitle_memory_mib=7776 recommended_working_set_mib=18186. Both runs had a warm shader cache (shaders_cached=21566 shaders_translated=0, prewarm done in 18 to 19 s).useResource per encoder)heap(a set per heap)VICTORY_HOLD_BYTE=1471b6330:1work held for a wait that does not holdheap_set_mbin the heap run: 1,675 at frames 64 to 512, 9,339 at frame 1024, 9,400 at frame 1536, 15,644 at frame 1984, 16,960 at frame 2048. That is the last counter line of the run, 53 s before the world frame starts.What the system did during the heap run (
memory_pressure, read every 15 s): the free percentage went down to 0 %, and the swap file grew from 8 to 10 GB. It was at 64 % a minute after the run.So on 24 GB the set reaches 17 GB of an 18.2 GB recommended working set before the world, no command buffer fails, and the world frames take a minute and a half each.
The slow stretch before the world is there in both modes, and it is not shader work or disk: no translation in either run, under 6 s of Metal compiles in it, and DirectStorage reads under 5 MB/s for most of it. The log lines of that stretch are the fence waits above and the title activating its spatial audio stream again.
Sound: the audio output fell back to silence (
AudioQueueStart failed with OSStatus 2003329396) on 4 of 14 stream activations in the default run and 6 of 32 in the heap run, the first at +188 s and +207 s.On screen, both runs: the loading artwork shows, smooth at first and then very slow, and the world is black.
Note on the default run: I was compiling on six cores during its last 85 s, from about +295 s on, so its world frame and its watchdog do not count. Everything before that does.
The heap run's binary also carried a local change to
victory translate --cache, which a run does not execute.I can attach both logs, or run again with other switches.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:22Z.
Thank you, the table is what I needed. The set jumps by about 5.8 GB in 9 seconds around frame 5200, and the first failed command buffer comes at 10,651 MB. That tells me the jump is one event, not a slow leak.
Your later run on #301 (a texture budget, no
OutOfMemoryfor 22 minutes) is the first sign that a byte budget helps on 16 GB. I have not run it myself.One question: at frames 5184 and 5248, what was the game doing (which screen)? If you still have the log lines between those two frames, please paste only the lines with
heaporresidencyin them, with your user name removed.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:24Z.
Thank you. This is a clear table. It says that on 24 GB the residency set is not the limit by itself: both modes reach the world with no GPU error, and the machine runs out of free memory first (free memory at 0%, swap 8 to 10 GB).
I do not need the full logs. If you can, please run once more with
VICTORY_TRACE_TEXTURE_SYNC=1and post thehost texture copieslines for the first 100 seconds after the world load (your #301 comment has the same numbers, so only if the head has changed). The slow stretch of 127 to 185 s before the world is the thing I want to understand next; please say what the log shows in it (fence waits, which queue).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by froziiik on 2026-11-27T17:50:40Z.
/claim — evicting covered placed textures across VA aliases and retired GPU epochs under a texture budget, and trimming unmapped leading fine mips on partial textures
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T17:50:50Z.
Claimed by @froziiik. Open a draft pull request with
Refs #8in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ItsMariusBC on 2026-11-27T18:12:18Z.
An answer to the slow stretch, later than I meant to: on this 24 GB Mac it is gone with
VICTORY_TEXTURE_DROP_TOP_MIP=1, and with the heap sets on top the world runs six to seven times faster than in the default mode, for the same free memory.Apple M5 Pro, 24 GB, macOS 27.2.1, main
4cf84c83with #327 merged (kept shader containers, not on this path), Series S, windowed, warm shader cache,VICTORY_HOLD_BYTE=1471b6330:1,--seconds 480, nothing building alongside. One run per column.DROP_TOP_MIP=1, default residencyDROP_TOP_MIP=1+RESIDENCY_SETS=heaprun-summary.sh)heap_set_mb, highestmemory_pressure, every 15 s)This morning, without the switch, the world's first binds came at +229 to +301 s after a stretch of 127 to 185 s at 0.4 fps, free memory went to 0 % and command buffers were lost. So the stretch was the Mac running out of memory, and the mip drop removes it in both residency modes.
What the default mode's world frames are made of. Three more runs on the same build, default residency, with the mip drop:
VICTORY_TRACE_RESIDENCY=1,VICTORY_PROFILE=30,VICTORY_TRACE_TEXTURE_SYNC=1:cb_commit0 ms and no "residency: slow call" in the whole run; texture sync tens to hundreds of ms a second; 310 "work held for a wait that does not hold" lines in the world, median 8.8 s, longest 17.2 s. I did not tally which queue.VICTORY_TRACE_COMMITS=1: in the world the GPU is busy 315 s of about 325; 91 command buffers of more than 1 s make 222 s of it, each of 47 to 119 passes.VICTORY_PASSES_PER_BUFFER=1: 10,964 passes in the world, 179 s ofgpu_ms, and none over 163 ms. The longest ones, whatever their shaders, all sit between 145 and 163 ms.That flat ceiling is what made me try the heap sets again: it is close to the per-pass cost I remember docs/native-host.md giving for
useResourceper encoder. My parse of that trace lost the content of most passes, so I cannot say which ones they are.The fault in the first heap run. Three first-chance
0xc0000005atimage+0x5149aecwithin 1 ms, then the reporter'simage+0x55e56f8, at frame 2145. Not the watchdog's0x23cf683, which the held byte still covers. It did not come back in the second run, which went further (frame 2209).On screen in the heap runs: a real picture, too dark as on main, with many more textures showing than at 0.3 fps.
So for 24 GB Macs both switches together look like the better default. I can run other combinations.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-27T19:17:43Z.
The same on a 24 GB M4 Pro (macOS 15.8.2): with
VICTORY_TEXTURE_DROP_TOP_MIP=1andVICTORY_METAL_RESIDENCY_SETS=heap, my runs get into the world and stay there.My setup: main
582670f1with two local changes (a title-watchdog patch and a UAV view level fix). Series S, windowed.VICTORY_HOLD_BYTE=1471b6330:1,VICTORY_DEPTH_TWINS=0. Runs of 300 s, stopped by my script if the memory level (kern.memorystatus_level, read 4 times a second) drops below 10 %.heap_set_mb, highestIn NV44 the drop came at frame 1893 (+166 s). There were 1,739 first binds in that frame, and the host copies grew from about 3.6 GB to 10 GB. The 19 frames after it took 131 s.
Without the two switches (NV40, NV41, main
4cf84c83with #359 and582670f1), both runs hit my memory limit at 75 to 84 s, before the world.A third run with the same build and switches (NV43) ended at
image+0x4dac5bfat +73 s, before the world (#339).In your heap runs, did the frame rate also drop when the host copies grew?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ItsMariusBC on 2026-11-27T19:29:53Z.
A correction to my comment above, and a warning for anyone on 24 GB (@alicans): I wrote that
VICTORY_TEXTURE_DROP_TOP_MIP=1withVICTORY_METAL_RESIDENCY_SETS=heaplooked like the better default. On this Mac the fourth run with that pair took the whole login session down. I withdraw the recommendation.Same Mac (Apple M5 Pro, 24 GB, macOS 27.2.1), main
b998bb65with #327 merged, Series S, windowed, warm shader cache,VICTORY_HOLD_BYTE=1471b6330:1, the two switches,--seconds 480. Two runs, an hour apart:heap_set_mb, highestrun-summary.sh)stopped the GPU's work; exiting in_flight=4 left=4at +249.6 sIn run 4, macOS's watchdog killed WindowServer at +246 s:
WindowServer-…ipswith"indicator":"monitoring timed out for service","namespace":"WATCHDOG", auserspace_watchdog_timeout.spinbeside it, and agpuEventreport 11 s later. Every open application went with it. The Mac did not reboot.So the GPU stall of run 3 was the warning, and I should have read it as one. The two earlier runs with the same pair (main
4cf84c83) had no GPU error at all, so I cannot say whether the difference is the newer main, the higher frame rate, or chance.The default residency with the mip drop has run several times here with no GPU error, at 0.3 fps. That is what I am back on.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 5ame-24 on 2026-11-28T02:21:49Z.
Setup: MacBook Pro M1 Max, 32 GB, macOS 26.6.2, Metal Shader Converter 4.0.3,
mainat226645f9, arm64 test build. No game files: a synthetic soak on the test rig, not a game run.A small leak that may add to the memory growth here, found without the game.
The submission path leaves Metal objects behind. The game's threads have no autorelease pool (only the pipeline-compile threads and the window loop have one), and Metal hands back autoreleased command buffers and encoders, so each
submit_passesleaves a few objects alive until the thread exits.How I saw it: a synthetic soak on the
state_tests.rsrig (a fresh list of 40 draws under four pipelines, execute, wait on a fence, repeat). Frame time stays flat at about 1 ms, but process memory climbs about 1.9 KB per submission, from 79 MB to 131 MB over 30,000 frames. It still grows with no draws and no textures. It stays flat (27 MB for 12,000 frames) when each frame runs inside an autorelease pool.Fix I tried: run the body of
submit_passesincrates/victory-metal/src/gfx.rsinsideobjc2::rc::autoreleasepool(|_| { ... }). With it, memory is flat at 73 MB over 12,000 frames. Without it, the soak grows 13 MB in 10,000 frames. Thevictory-gpuandvictory-metalsuites pass on arm64 with MSC 4.0.3.What I have not shown: how many submissions the title makes per frame, or whether leaked command buffers keep large resources alive (that would be far worse than 2 KB each). The 16 GB failure here is gigabytes, so this is at most a contributor.
footprint_mbis already in thenative draws so farline, so a long run's log would show a steady climb if it matters.Happy to share the soak test and the patch in whatever form suits.