Skip to content

Mario Kart World maps no memory past its application pool (mem_map_limit on): free roam's footprint stays near 4 GB - #1594

Closed
lossefanya wants to merge 1 commit into
seedds:mainfrom
lossefanya:mkw/mem-map-limit
Closed

lossefanya wants to merge 1 commit into
seedds:mainfrom
lossefanya:mkw/mem-map-limit

Conversation

@lossefanya

@lossefanya lossefanya commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Refs #1536.

Symptom. In free roam, Mario Kart World's memory keeps growing as the world streams in. On a 16 GB M1 Pro the footprint went from 7.8 to 9.4 GB in 12 minutes, macOS compressed 4.5 GB of it, and swap grew. Most of it is the game's own memory (charged 3.9 → 5.3 GB); the host's GPU memory grew only 0.3 GB. Grand Prix races do not show it.

Cause. MapPhysicalMemory past the 9 GB application pool succeeds on the host, where Horizon fails it, so the game's streaming keeps mapping new blocks instead of freeing its own.

Change. The profile sets mem_map_limit on, a key five profiles already use. The host and tools are unchanged. The alias region now peaks at 1.5–1.75 GB mapped instead of 3.0 GB, which matches what #1536 found on an 8 GB Mac. The game note gets a row in its settings table and a new section, Memory in free roam.

Checked

Mario Kart World v0, free roam, handheld (DM_OPMODE=0), M1 Pro 16 GB, macOS 27.2.

Build Run Footprint Wired Swap
main, no limit, no DM_GUEST_FILE headless scripted drive, 12 min 7.8 → 9.4 GB grows
main b2d46b86 + this, DM_GUEST_FILE=1 played in a window, 26 min 4.6–4.7 GB, start to end 6.3–6.9 GB flat
+ #1592's table fix, #1179, #1229, #1230, #1251, #1350, DM_GUEST_FILE=1 headless, 13 min 3.8–4.0 GB flat
same played, 20 min 4.4 GB at the end flat
  • Tests: dm/tools/tests/test_game_profile.py, test_docs.py.
  • Not separated: the limit alone without DM_GUEST_FILE. With the files on, the footprint counts no file pages, so the limit's own effect shows in the alias region's peak, not in the footprint.
  • Cost of DM_GUEST_FILE: more long frames late in a session (1.35/s over 20 minutes vs 0.65–0.73/s without) and about 8 GB of temp files while the game runs. The note says so; it stays a player's choice.
  • Not run on an 8 GB Mac or an iPhone.

Frame rate (not changed by this PR)

For context, on the branch with the other PRs cherry-picked (row 3 above):

  • Grand Prix runs near 60 fps; free roam still drops to about 40 fps in heavier areas.
  • Main with only this change: about 40 fps in free roam (game frame time median 22–24 ms).
  • So the frame rate comes from those PRs, the flat memory from this one, and free roam's frame rate is still open.
  • That branch ran with dynamic resolution off (no gpu_timestamps segment; with it, distant scenery flickered), and Mario Kart World's cube-map prefilter is drawn one face at a time: profile key split_outputs #1251 needed its MSL extracted by hand.

Docs

  • The finding is in the game note (Memory in free roam); docs_symptoms.py shows no change (no reference entry)
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

@github-actions github-actions Bot added docs Documentation game: 0400C3F00006E000 A game profile labels Nov 6, 2026
…mit on): in free roam the game frees its own blocks, and its footprint stays near 4 GB with DM_GUEST_FILE

Free roam streams the world, and the memory kept growing: on a 16 GB M1 Pro, handheld, a
scripted drive into new areas took the footprint from 7.8 to 9.4 GB in 12 minutes (the game's
charged memory 3.9 to 5.3 GB, 4.5 GB compressed, swap growing). Most of it was the game's own
memory, which the host cannot give back without knowing what the game still needs.

With mem_map_limit on, MapPhysicalMemory past the 9 GB pool fails as on Horizon, and the
game's streaming frees its own blocks: its alias region peaked at 1.5 GB mapped where it had
3.0 GB, as issue seedds#1536 found on an 8 GB Mac. With DM_GUEST_FILE=1 as well, the footprint
stayed at 3.8 to 4.4 GB over 13 to 17 minutes, compressed memory under 0.6 GB, swap flat,
wired unchanged. The cost is more long frames: a 20-minute played windowed run (Grand Prix and
free roam) had 1.35 long frames a second (21 over 100 ms) against 0.65-0.73 without the files. Measured on
a branch that also had pull requests seedds#1179, seedds#1229, seedds#1230, seedds#1251 and seedds#1350.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simo501

simo501 commented Nov 6, 2026

Copy link
Copy Markdown

Does it run 60fps on m1 pro?

@lossefanya

Copy link
Copy Markdown
Contributor Author

Does it run 60fps on m1 pro?

near 60. In grand prix, around 57, depends on map.
Without mem_map_limit it can achieve 60fps. But ram consumption grows over time.

@simo501

simo501 commented Nov 7, 2026

Copy link
Copy Markdown

I was asking because grand prix only reaches 42-43FPS at best on my M1 pro

@lossefanya

Copy link
Copy Markdown
Contributor Author

I was asking because grand prix only reaches 42-43FPS at best on my M1 pro

Right, this PR fixes memory issue but lowers performance.
There're other PRs which I mentioned in PR description.
With combination of them, I could see improvements on my test branch.

Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…es span every channel of their submap (GitHub PR seedds#60)

stb_vorbis cut a type-2 residue's interleaved vector at n * 2 values even when its submap holds more channels, so the rest of the packet was read as the wrong data: the 5.1 tracks libvorbis encodes came out distorted and gurgling, with pops. The bound is now n * ch, as in the Vorbis spec and libvorbis's res2_inverse, and the temporary-memory estimate for a caller-owned buffer counts every channel of the stream for type-2 residues (with the decode fix alone, a 6-channel stream overran the advertised buffer). Upstream stb still has the bug (nothings/stb seedds#879, seedds#1594).
Link's Awakening's opening and title movies were the report; DRAGON QUEST XI S's movies open only 6-channel Vorbis tracks too. Its 23 6-channel cutscene and title tracks, decoded as the host does, now match FFmpeg to within 0.02 PCM16 units, where main's decoder was off by an RMS of 1,700 to 70,000 units.
dm/host/tests/t_vorbis builds tiny Vorbis streams in memory (types 0/1/2, mono to 8 channels, two submaps) and checks heap and fixed-buffer decoding through the pull and push APIs, with and without STB_VORBIS_DIVIDES_IN_RESIDUE; it needs no game profile. dmhost rebuilds when stb_vorbis.c changes.
On top of the PR: the test rules sit with the others, and the stb_vorbis README and the per-game notes say what the fix repairs.

Co-authored-by: ohxiaoguang <44696970+ohxiaoguang@users.noreply.github.com>
oliverames pushed a commit to oliverames/nxnative that referenced this pull request Nov 9, 2026
xyzl1789 pushed a commit to xyzl1789/nxnative that referenced this pull request Nov 12, 2026
…es span every channel of their submap (GitHub PR seedds#60)

stb_vorbis cut a type-2 residue's interleaved vector at n * 2 values even when its submap holds more channels, so the rest of the packet was read as the wrong data: the 5.1 tracks libvorbis encodes came out distorted and gurgling, with pops. The bound is now n * ch, as in the Vorbis spec and libvorbis's res2_inverse, and the temporary-memory estimate for a caller-owned buffer counts every channel of the stream for type-2 residues (with the decode fix alone, a 6-channel stream overran the advertised buffer). Upstream stb still has the bug (nothings/stb seedds#879, seedds#1594).
Link's Awakening's opening and title movies were the report; DRAGON QUEST XI S's movies open only 6-channel Vorbis tracks too. Its 23 6-channel cutscene and title tracks, decoded as the host does, now match FFmpeg to within 0.02 PCM16 units, where main's decoder was off by an RMS of 1,700 to 70,000 units.
dm/host/tests/t_vorbis builds tiny Vorbis streams in memory (types 0/1/2, mono to 8 channels, two submaps) and checks heap and fixed-buffer decoding through the pull and push APIs, with and without STB_VORBIS_DIVIDES_IN_RESIDUE; it needs no game profile. dmhost rebuilds when stb_vorbis.c changes.
On top of the PR: the test rules sit with the others, and the stb_vorbis README and the per-game notes say what the fix repairs.

Co-authored-by: ohxiaoguang <44696970+ohxiaoguang@users.noreply.github.com>
kingbumi31 pushed a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…ation pool (mem_map_limit on) (seedds)

A bug fix: the host mapped memory past the 9 GB pool where Horizon refuses, so the game's streaming never freed its own blocks and free roam grew without bound (7.8 to 9.4 GB in 12 minutes on a 16 GB M1 Pro, the author's measurement).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…ation pool (mem_map_limit on) (seedds)

A bug fix: the host mapped memory past the 9 GB pool where Horizon refuses, so the game's streaming never freed its own blocks and free roam grew without bound (7.8 to 9.4 GB in 12 minutes on a 16 GB M1 Pro, the author's measurement).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
kingbumi31 added a commit to kingbumi31/no-lag-kart that referenced this pull request Nov 15, 2026
…ation pool (mem_map_limit on) (seedds)

A bug fix: the host mapped memory past the 9 GB pool where Horizon refuses, so the game's streaming never freed its own blocks and free roam grew without bound (7.8 to 9.4 GB in 12 minutes on a 16 GB M1 Pro, the author's measurement).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcmewFJDrDUooyBk9ygMAv
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 15, 2026
…ation pool (mem_map_limit on): free roam's footprint stays near 4 GB

The settings table drops the PR's render_cond row (the key is gone on main); its Memory in free roam section follows the Frame rate section.
@seedds

seedds commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @lossefanya for diagnosing Mario Kart World's free-roam memory growth and sharing your measurements.

Closing this PR because a694f179 (PR #3188) now enables Horizon's application-pool memory limit (mem_map_limit) automatically by default for all Switch 2 games, including Mario Kart World, so a per-game profile setting is no longer needed. The host memory and profile tests pass on main.

Still open: free roam's frame rate and an isolated memory check without DM_GUEST_FILE=1.

@seedds seedds closed this Nov 25, 2026
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 27, 2026
…ile): closed, superseded by a694f17 (seedds#3188: Horizon's application-pool memory limit on by default for every Switch 2 game); its free-roam measurement goes with it
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 27, 2026
…d first; Store.slim (seedds#2470) reads main's v2 cache schema; chain 2d0bb91984e7 -> ce42b3f44d72

Reverted before this merge (each its own commit): on main in its own form or superseded: seedds#1978 (1e06abd), seedds#3195 (8c7660d, discussion seedds#3291), seedds#2140 (62bcfd2), seedds#1594 (a694f17), seedds#1847's host changes (473c90d, 1999cbd), seedds#2173 (main's discussion-fed list), ef13ece's port of seedds#2390 (5fa41f3); closed upstream with nothing on main, at the user's choice: seedds#1827, seedds#1765, seedds#1642, seedds#1847's Bananza render scale (7984715), seedds#1717, seedds#2251, seedds#2259, seedds#2226.

Conflicts: the frame lag ring (seedds#2074) beside main's acquire-next receipts (1999cbd): frame_lag_wait after main's offscreen early return, frame_lag_note before main's next_ticket bookkeeping, nvn_queue_present_hold / ticket_fence beside main's nq_receipt_wait_published; the prebuild tool's timer still writes nothing (da2808f) beside main's batched archive writes (4d62497), whose removal of the 1,000-capture flushes matches fa1df04; t_pso_archive runs both tool_write_waits_for_compiles and batch_wave; seedds#2470's slim argument kept beside main's pruning step and GL shader build; tests.yml takes main's list plus t_lag; t_audio_device keeps test_route_choice (main moved wait_for_phase up); development.md takes main's compressed-cache sentence plus seedds#2470's; rendering.md keeps seedds#2388's "3D upscaler" label in main's new text; the chain header is main's (dmsh_chain.py --header gives the same value).

Merge fix: Store.slim measured index entries with length(b.data), a column main's v2 schema (5fa41f3) renamed to payload; it now picks the column as prune_shaders does, and its test counts stored bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400C3F00006E000 A game profile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants