Skip to content

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

Closed
poonasor wants to merge 1 commit into
boykopovar:mainfrom
poonasor:fix/libkernel-flexible-memory-size-from-param-json
Closed

poonasor wants to merge 1 commit into
boykopovar:mainfrom
poonasor:fix/libkernel-flexible-memory-size-from-param-json

Conversation

@poonasor

@poonasor poonasor commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added libkernel docs needs rebase Conflicts with main, rebase needed labels Oct 12, 2026
@poonasor
poonasor force-pushed the fix/libkernel-flexible-memory-size-from-param-json branch from c35ef21 to 5e4b06d Compare October 12, 2026 19:10
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
9 tasks done
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@poonasor
poonasor force-pushed the fix/libkernel-flexible-memory-size-from-param-json branch from 5e4b06d to 3f8bc39 Compare October 12, 2026 20:48
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
The flexible memory budget was a fixed 448 MiB. A title can declare
its own in param.json (kernel.flexibleMemorySize, in bytes); that value
now sets the budget for sceKernelConfiguredFlexibleMemorySize,
sceKernelAvailableFlexibleMemorySize and the flexible maps.

NHL 27 (PPSA34063) declares 560 MiB and ran out of flexible memory in
its menus with 448 MiB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@poonasor
poonasor force-pushed the fix/libkernel-flexible-memory-size-from-param-json branch from 3f8bc39 to 55ee567 Compare October 12, 2026 22:06
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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.

@adriadam10 adriadam10 closed this Oct 13, 2026
@poonasor
poonasor deleted the fix/libkernel-flexible-memory-size-from-param-json branch October 13, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants