fix(libkernel): take the flexible memory size from param.json #4617

Closed
poonasor wants to merge 1 commit from upstream-pr/4617 into main
poonasor commented 2026-10-12 16:50:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by poonasor on 2026-10-12T16:50:10Z.


What

The flexible memory budget is a fixed 448 MiB. A title can declare its own in param.json:

"kernel": {"flexibleMemorySize": 587202560}

A commercial title declares 560 MiB. Since the segments of the title's executable count against the budget, it runs out about 20 minutes after its title screen and writes through the null result:

[memory] flexible memory exhausted: request 0x200000 with 0x1be38000 of 0x1c000000 in use

FATAL: unhandled exception 0xc0000005 on thread 32116 'Unknown(Registered)'
  rip 0x00007ff7c410a1ab title.exe+0xd1a1ab
  write of 0x0000000000000000

The title does not reach this point on main alone (it stops earlier on missing functions, #4544 and others); the lines are from c6efe068a with those added on my fork (dev-next).

parseParamJson now reads kernel.flexibleMemorySize (a non-negative integer, bytes; anything else throws), and sceKernelConfiguredFlexibleMemorySize, sceKernelAvailableFlexibleMemorySize and the flexible maps use it. Without the member, or without a param.json, the budget stays 448 MiB.

Not known and recorded in TechnicalDebt: whether the console takes a larger flexible budget out of the direct memory pool, and which values it accepts.

Tested

Windows 11, MinGW-w64 GCC 15.2, AMD RX 6700 XT.

  • param_json_parser extended: absent kernel, empty kernel, a valid size, and six rejected forms (non-object, negative, fraction, exponent, string, above uint64). It does not build on main (no flexibleMemorySize field) and passes with this change.
  • ctest -R "param_json|guest_memory": 4 of 4 pass.
  • The title: with this change the message no longer appears and the title goes on through its main menu into Play Now team select (57 minutes so far, no memory failure).
  • python tools/check_conventions.py --base origin/main passes.

Not tested: Linux, macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832439058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4617). Originally posted by [poonasor](https://github.com/poonasor) on 2026-10-12T16:50:10Z. --- ### What The flexible memory budget is a fixed 448 MiB. A title can declare its own in `param.json`: ```json "kernel": {"flexibleMemorySize": 587202560} ``` A commercial title declares 560 MiB. Since the segments of the title's executable count against the budget, it runs out about 20 minutes after its title screen and writes through the null result: ``` [memory] flexible memory exhausted: request 0x200000 with 0x1be38000 of 0x1c000000 in use FATAL: unhandled exception 0xc0000005 on thread 32116 'Unknown(Registered)' rip 0x00007ff7c410a1ab title.exe+0xd1a1ab write of 0x0000000000000000 ``` The title does not reach this point on `main` alone (it stops earlier on missing functions, #4544 and others); the lines are from `c6efe068a` with those added on my fork ([`dev-next`](https://github.com/poonasor/AnyPS5/tree/dev-next)). `parseParamJson` now reads `kernel.flexibleMemorySize` (a non-negative integer, bytes; anything else throws), and `sceKernelConfiguredFlexibleMemorySize`, `sceKernelAvailableFlexibleMemorySize` and the flexible maps use it. Without the member, or without a `param.json`, the budget stays 448 MiB. Not known and recorded in TechnicalDebt: whether the console takes a larger flexible budget out of the direct memory pool, and which values it accepts. ### Tested Windows 11, MinGW-w64 GCC 15.2, AMD RX 6700 XT. - `param_json_parser` extended: absent `kernel`, empty `kernel`, a valid size, and six rejected forms (non-object, negative, fraction, exponent, string, above uint64). It does not build on `main` (no `flexibleMemorySize` field) and passes with this change. - `ctest -R "param_json|guest_memory"`: 4 of 4 pass. - The title: with this change the message no longer appears and the title goes on through its main menu into Play Now team select (57 minutes so far, no memory failure). - `python tools/check_conventions.py --base origin/main` passes. Not tested: Linux, macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-12 23:06:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T23:06:23Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4508 core/libs/prx/libkernel/AppMetadata/include/ParamJsonParser.hpp L12
core/libs/prx/libkernel/DirectMemory/Export.cpp L39, L100-101, L365, L371
docs/dev/debt/libkernel.md L40
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134324775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4617#issuecomment-6134324775). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T23:06:23Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4508 | `core/libs/prx/libkernel/AppMetadata/include/ParamJsonParser.hpp` [L12](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/core/libs/prx/libkernel/AppMetadata/include/ParamJsonParser.hpp#L12)<br>`core/libs/prx/libkernel/DirectMemory/Export.cpp` [L39](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/core/libs/prx/libkernel/DirectMemory/Export.cpp#L39), [L100-101](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/core/libs/prx/libkernel/DirectMemory/Export.cpp#L100-L101), [L365](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/core/libs/prx/libkernel/DirectMemory/Export.cpp#L365), [L371](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/core/libs/prx/libkernel/DirectMemory/Export.cpp#L371)<br>`docs/dev/debt/libkernel.md` [L40](https://github.com/boykopovar/AnyPS5/blob/2f5c3a4bf5d114e611f2ec039f30275d0edab1f4/docs/dev/debt/libkernel.md#L40) | | |
xXPBSXx commented 2026-10-13 06:43:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:43:00Z.


Windows test: head 55ee567e2 merged onto current main ea2bbefb2 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter param_json_parser: param_json_parser passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139898026 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4617#issuecomment-6139898026). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T06:43:00Z. --- Windows test: head `55ee567e2` merged onto current `main` `ea2bbefb2` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `param_json_parser`: param_json_parser passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
adriadam10 commented 2026-10-13 14:45:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:45:00Z.


Closing as a duplicate of #4508, which was opened earlier and implements the same thing: kernel.flexibleMemorySize from param.json used by sceKernelConfiguredFlexibleMemorySize, sceKernelAvailableFlexibleMemorySize and the flexible maps, in the same files (ParamJsonParser, DirectMemory/Export.cpp, docs/dev/debt/libkernel.md). It also validates 16 KiB alignment, covers guest-memory accounting in tests and already has review comments.

Your evidence (NHL 27 / PPSA34063 declaring 587202560 and the exhaustion log) is useful there: please add it to #4508 as a comment. Welcome to reopen if #4508 ends up not covering your case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148198512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4617#issuecomment-6148198512). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:45:00Z. --- Closing as a duplicate of #4508, which was opened earlier and implements the same thing: `kernel.flexibleMemorySize` from `param.json` used by `sceKernelConfiguredFlexibleMemorySize`, `sceKernelAvailableFlexibleMemorySize` and the flexible maps, in the same files (`ParamJsonParser`, `DirectMemory/Export.cpp`, `docs/dev/debt/libkernel.md`). It also validates 16 KiB alignment, covers guest-memory accounting in tests and already has review comments. Your evidence (NHL 27 / PPSA34063 declaring 587202560 and the exhaustion log) is useful there: please add it to #4508 as a comment. Welcome to reopen if #4508 ends up not covering your case.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4617
No description provided.