Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reference: what a Switch 2 game's first 3D load does to an iPhone's G…
…PU memory (Ocarina of Time on an iPhone Duo)
  • Loading branch information
Oliver Ames
Oliver Ames committed Nov 10, 2026
commit 76fd3c24d39399bbaf9ace4144d64beccfdc42b4
1 change: 1 addition & 0 deletions docs/agents/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
- travelling produces a brief multi-GB footprint spike, then memory returns to its earlier level; periodic memory lines can miss the peak. Upload diagnostics show many swapped-out blocks still alive in one batch. → [Upload staging grows within one rendering submission](../reference/memory.md#upload-staging-grows-within-one-rendering-submission)
- GPU memory grows with repeated `nvnTextureReadTexels` calls on a long-lived game thread, even after each readback completes. → [GPU readback without an autorelease pool](../reference/memory.md#gpu-readback-without-an-autorelease-pool)
- process footprint and Metal allocation grow during stationary gameplay even after readback fences complete; the deferred-release queue and command allocator sizes remain bounded. → [Completion readbacks survive a guest waiter's pool](../reference/memory.md#completion-readbacks-survive-a-guest-waiters-pool)
- the game plays its menu and movies, then at the first 3D load `GPU allocated` jumps by about 5 GB. The log has `[RED] GPU out of memory`, then a GPU page fault and `kIOGPUCommandBufferCallbackErrorSubmissionsIgnored`. The game keeps running with audio and a black screen, because every later submission is refused. Without guest files (`DM_GUEST_FILE`), the same load can instead end in a Jetsam report with reason `vm-pageshortage` on nearly every process. → [A Switch 2 game's first 3D load on an iPhone](../reference/memory.md#a-switch-2-games-first-3d-load-on-an-iphone)
- `footprint` shows `Malloc Large` about the size of `pso_archive/` (the log's `pipeline archive …: N files, … MB`), resident or swapped for the whole run. `MallocStackLogging=1` with `malloc_history <pid> -allBySize` gives `newArchiveWithURL` → `MTL4ArchiveImpl::loadFromURL` → `LoaderGlobalState::loadFile` → `-[NSData initWithContentsOfFile:options:maxLength:error:]` → malloc. → [A pipeline archive on an external drive is read into memory](../reference/memory.md#a-pipeline-archive-on-an-external-drive-is-read-into-memory)
- the periodic `residency set up to frame` line shows hundreds of allocations added and removed per 300 frames in a scene where nothing loads: Ocarina of Time, 1,500 (`pool_gpu` 900 of 180 KB, `mrbuf_get` 600 of 0.5 MB), and 650 commits. → [Pool tables and readback buffers made anew each frame](../reference/memory.md#pool-tables-and-readback-buffers-made-anew-each-frame)
- with a profile that has `tex_dirty_upload`, a texture in a sparse pool that the game draws into or writes as an image logs `CPU-written texture ser=…` at its first use, and takes its content from its storage. `t_sparse_tiles` crashed at `and unmapped, not drawn: its heap tile goes back` when built with such a profile, and passed with one without the key. → [A texture in a sparse pool came out CPU-written at its first use](../reference/memory.md#a-texture-in-a-sparse-pool-came-out-cpu-written-at-its-first-use)
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ The guest address space, heaps, pools, virtual address memory and the allocators
- **Check:** `make -C dm/gfx/tests GAME=<id> check_t_readback` (`store_completion`) gates real GPU feedback and exercises both `DM_NVN_FAST_WAKE=1` guest-owned completion and `0` callback-owned completion, with the guest waiter's outer pool open throughout. It checks literal copied pixels in the storage and event visibility at a successful wait, and delayed-feedback idempotence. Its buffer-lifetime assertion went with the readback into storage (2026-11-10, now [stored on the GPU](nvn-objects.md#gpu-textures-in-storage-the-cpu-can-read)), whose landed buffer it watched; the pool still covers the visibility buffers `post_run` reads, which no test watches.
- **Found on:** [Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md#memory), M2 Pro stationary cave route. A bounded paired diagnostic on chain `d1043b780a74` showed footprint growth of 617 MiB over about 86 seconds without the pool versus 1 MiB over about 83 seconds with it. This is route-local memory evidence, not an FPS improvement, complete allocation census or verified fix for an iPhone termination.

### A Switch 2 game's first 3D load on an iPhone

- **Symptom:** the game plays its menu and movies, then at the first 3D load `GPU allocated` jumps by about 5 GB. The log has `[RED] GPU out of memory`, then a GPU page fault and `kIOGPUCommandBufferCallbackErrorSubmissionsIgnored`. The game keeps running with audio and a black screen, because every later submission is refused. Without guest files (`DM_GUEST_FILE`), the same load can instead end in a Jetsam report with reason `vm-pageshortage` on nearly every process.
- **Cause:** the first raw global memory table makes every memory pool resident at once, and that charges each zero-copy buffer's whole length to the GPU. Measured on the failing run: 8,163 MB in the residency set against 8,192 MB of `recommendedMaxWorkingSetSize`, with 5,793 MB of shared buffers (2,432 MB of it the alias region pool as one buffer) and 1,973 MB of textures. The error came just under the recommended size, so that value is not an exact limit. The three kernel memory entitlements did not raise it.
- **Status:** open. Guest files took the footprint during a movie from about 4,700 to 555 MB, and the load then got further, but they do not change what the residency set charges, and they added 60 to 80 ms frames during movies. A smaller application pool (the cap of PR #1104) does not help this game: its heap request falls with the pool, and caps of 7 and 8.5 GB both crashed at boot. The remaining work is to charge less for each pool and to stop [holding textures twice](https://github.com/seedds/nxnative/issues/1281).
- **Check:** `res_top`'s `GPU out of memory` line gives the totals by kind and the largest objects. Read the `reason` of the Jetsam report, because a process limit and a system-wide page shortage need different fixes.
- **Found on:** The Legend of Zelda: Ocarina of Time (`0400486024DEC000`, v131072), iPhone Duo (iPhone19,4), iOS 27.3, docked, with PRs #1299, #1300 and #1312 (since closed) applied.

### A pipeline archive on an external drive is read into memory

- **Symptom:** `footprint` shows `Malloc Large` about the size of `pso_archive/` (the log's `pipeline archive …: N files, … MB`), resident or swapped for the whole run. `MallocStackLogging=1` with `malloc_history <pid> -allBySize` gives `newArchiveWithURL` → `MTL4ArchiveImpl::loadFromURL` → `LoaderGlobalState::loadFile` → `-[NSData initWithContentsOfFile:options:maxLength:error:]` → malloc.
Expand Down