Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Request Increased Memory Limit

LNPANDYe0d4b1e3b7dd
diff --git a/dm/gfx/tools/dmsh_chain.lock b/dm/gfx/tools/dmsh_chain.lock
index 00abb656..8cc6369b 100644
--- a/dm/gfx/tools/dmsh_chain.lock
+++ b/dm/gfx/tools/dmsh_chain.lock
@@ -3,6 +3,6 @@ dmsh_xlate.dll a7f696bb0dbf1ac0
Ryujinx.Graphics.Shader.dll a4b556413e6a98f5
Ryujinx.Common.dll 5222da62ffb43db1
xlate_source 38a1c0b4e3ebd5fa
-spirv-cross d9dc197f061b42a5
+spirv-cross 242d2c694be3ec91
metal_macosx Apple metal version 32023.921 (metalfe-32023.921.6)
metal_iphoneos Apple metal version 32023.921 (metalfe-32023.921.6)
diff --git a/dm/ios/ENTITLEMENTS.md b/dm/ios/ENTITLEMENTS.md
new file mode 100644
index 00000000..1049e333
--- /dev/null
+++ b/dm/ios/ENTITLEMENTS.md
@@ -0,0 +1,76 @@
+# Increased Memory Limit
+
+The app ships `com.apple.developer.kernel.increased-memory-limit` in its entitlements
+(`Sources/DmIOS.entitlements`, wired in through `CODE_SIGN_ENTITLEMENTS` in `project.yml`).
+
+## Why it matters
+
+iOS gives an app a per-process physical-memory budget and kills it (jetsam, SIGKILL, no crash
+report) when it goes over. On current iPhones that budget is about **3.3 GB** without the
+entitlement and **6–8 GB** with it, depending on the device.
+
+Measured here, both on a 12 GB iPhone:
+
+| Game | Peak resident | Headroom | Result |
+|---|---|---|---|
+| Tears of the Kingdom | 3,342 MB | 33 MB | killed entering the world map |
+| Hades II | — | — | asks for a 3.10 GB heap; at the budget limit |
+
+Lowering the render scale to 0.5 did not change the Tears of the Kingdom outcome, so the limit is
+the guest heap rather than the GPU. The only way past it is a higher budget.
+
+## What the entitlement needs
+
+Two conditions, both required:
+
+1. **The signature carries it.** `build_ipa.sh` builds unsigned (the sideloader re-signs), so what
+ matters is whether the sideloader copies unknown entitlements from the IPA into its own signature
+ instead of dropping them.
+2. **The App ID has it enabled.** The provisioning profile a sideloader generates only includes
+ entitlements the App ID is registered for. The sideloader has to ask Apple for it.
+
+## Which sideloaders keep it
+
+Reported by [playport.dev](https://playport.dev/) (a different project with the same requirement):
+
+| Sideloader | Keeps the entitlement |
+|---|---|
+| AltStore Classic 2.2 or later | Yes |
+| Impactor (from a computer) | Yes |
+| Xcode with a Personal Team | Yes |
+| SideStore 0.7.0, free Apple ID | Not by default — see below |
+| Sideloadly and others | Check the tool; Sideloadly does not enable it |
+
+## SideStore with a free Apple ID
+
+The entitlement attaches to the App ID, so it survives the weekly refresh once set. One-time fix:
+
+1. Install this app through SideStore, so its App ID has been created with Apple.
+2. Sideload **GetMoreRam** and sign in with the same Apple ID SideStore uses.
+3. In GetMoreRam open **App IDs**, tap **Refresh**, select this app's App ID, then
+ **Add Increased Memory Limit**.
+4. Reinstall the app from SideStore (it upgrades in place; `Documents/` — the RomFS archive and the
+ saves — is preserved).
+5. Confirm: `Documents/log.txt` should now show a much larger `headroom to the system memory limit`
+ in the `memory up to frame N` lines. GetMoreRam uses one of a free Apple ID's three app slots, so
+ delete it afterwards if you need the slot back.
+
+## Checking whether it took effect
+
+Launch the game, let it run a few hundred frames, then read the memory line in `Documents/log.txt`:
+
+```
+memory up to frame 600: resident 3342 MB, ... headroom to the system memory limit 33 MB
+```
+
+- `headroom` in the low tens of MB, then the log stops with no `CRASH sig=` line → no entitlement.
+- `headroom` in the hundreds of MB or more at the same frame count → the entitlement is active.
+
+`os_proc_available_memory()` is what produces that number (`dm/gfx/nvn/nvn_mtl.m`), and it reports
+the distance to the budget the kernel enforces.
+
+## Xcode route
+
+With a Personal Team and a real device, add the capability in Xcode
+(Signing & Capabilities → + Capability → Increased Memory Limit) and build from there. That is the
+one route where the app is signed at build time, so no re-signing step can drop the entitlement.
diff --git a/dm/ios/Sources/DmIOS.entitlements b/dm/ios/Sources/DmIOS.entitlements
new file mode 100644
index 00000000..d9dc2749
--- /dev/null
+++ b/dm/ios/Sources/DmIOS.entitlements
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <!-- Raise the per-process physical memory (jetsam) limit. Without it an iPhone
+ gives this app about 3.3 GB, which stops large titles (Tears of the Kingdom
+ reaches its budget entering the world map; Hades II asks for a 3.10 GB heap).
+
+ The entitlement has to be present in the signature AND enabled on the App ID
+ for the provisioning profile to carry it. A sideloader that drops unknown
+ entitlements will ignore this; see dm/ios/ENTITLEMENTS.md for which tools
+ keep it and how to attach it to an App ID with a free Apple ID. -->
+ <key>com.apple.developer.kernel.increased-memory-limit</key>
+ <true/>
+</dict>
+</plist>
diff --git a/dm/ios/project.yml b/dm/ios/project.yml
index 6ecf41ed..e20667a5 100644
--- a/dm/ios/project.yml
+++ b/dm/ios/project.yml
@@ -55,6 +55,11 @@ targets:
CURRENT_PROJECT_VERSION: ${DM_APP_VERSION}
DEVELOPMENT_TEAM: ${DM_TEAM_ID}
CODE_SIGN_STYLE: Automatic
+ # Increased Memory Limit: the app requests a higher jetsam budget (6-8 GB instead of ~3.3 GB).
+ # build_ipa.sh builds unsigned (CODE_SIGNING_ALLOWED=NO), so this only records the request in the
+ # app's signature; the sideloader has to keep it and the App ID has to have it enabled. See
+ # dm/ios/ENTITLEMENTS.md.
+ CODE_SIGN_ENTITLEMENTS: Sources/DmIOS.entitlements
ASSETCATALOG_COMPILER_APPICON_NAME: $(DM_APPICON) # Gen/dm.xcconfig sets DM_APPICON = AppIcon when there is a game icon; empty = no icon (xcodegen's default is AppIcon, which fails the build when the catalog lacks it)
TARGETED_DEVICE_FAMILY: "1,2"
ENABLE_BITCODE: NO
diff --git a/dm/ios/tools/build_ipa.sh b/dm/ios/tools/build_ipa.sh
index 79cb8157..62884b70 100755
--- a/dm/ios/tools/build_ipa.sh
+++ b/dm/ios/tools/build_ipa.sh
@@ -77,6 +77,11 @@ APP=$DD/Build/Products/Release-iphoneos/DmIOS.app; [ -d "$APP" ] || APP=$(grep -
# the app sets DM_AOC_DIR at launch, the host reports them as owned and mounts them from it) and the RomFS
rm -rf "$APP/msl" "$O/Payload" "$O/out.ipa" # (the last two: what the copy-and-zip packing left behind)
P=Payload/DmIOS.app; MAPS=("$P=$APP" "$P/msl/$MSLDIR=$MSL_IOS/$MSLDIR")
+# Increased Memory Limit: the build is unsigned, so Xcode never merges Sources/DmIOS.entitlements into
+# a signature. Ship the file inside the app bundle anyway so a sideloader that looks for it there can
+# pick it up. See dm/ios/ENTITLEMENTS.md.
+cp Sources/DmIOS.entitlements "$APP/DmIOS.entitlements" || die "copy entitlements into the app bundle"
+t "entitlements: com.apple.developer.kernel.increased-memory-limit requested (see dm/ios/ENTITLEMENTS.md)"
if [ -n "$AOC" ] && [ -d "$AOC" ]; then MAPS+=("$P/aoc=$AOC"); t "add-on content: $(ls "$AOC" | tr '\n' ' ')"; fi
# DM_NO_ROMFS=1: leave the RomFS out of the package. The app then reads it from Documents/romfs
# (a directory tree, or a ROMFSARC archive: romfs.idx + romfs.NN shards, see dm/host/romfs_arc.h).