Allow savestate undo disable for pcsx_rearmed on old3ds#18755
Merged
LibretroAdmin merged 5 commits intolibretro:masterfrom Feb 22, 2026
Merged
Allow savestate undo disable for pcsx_rearmed on old3ds#18755LibretroAdmin merged 5 commits intolibretro:masterfrom
LibretroAdmin merged 5 commits intolibretro:masterfrom
Conversation
This frees ~160k of RAM without any downsides that I know of. It's not much, but helps pcsx_rearmed on old3ds where it barely fits in RAM.
Regardless if `save_state_in_background` is enabled or not, it does exactly the same so the check can be removed.
content_load_state_from_ram() doesn't need the backup copy, content_save_state() never touches the ram_buf. It seems the whole logic was copy-pasted from content_undo_load_state() without thinking.
Just take the source pointer instead of making a copy and then freeing it. This is a big deal on slow platforms having to deal with large states, like psx on old3ds.
The undo feature may amount to at least 4 simultaneous buffers: save undo, load undo, the current save/load buffer, temporary buffer. When emulating a system with relatively large states on a system with little RAM (like PSX on old3ds) that amounts to something like ~18MB of ~42MB available to the core. Under memory pressure the libctru variation in RetroArch tries to salvage some memory from the main stack and linear memory, but since those are variable, they start to overlap creating instability. The solution is to just disable the undo feature.
notaz
added a commit
to notaz/pcsx_rearmed
that referenced
this pull request
Feb 23, 2026
needs libretro/RetroArch#18755 also log mem info in more cases
Contributor
Wouldn't it be better to reserve a new ID from libretro.h eventually? |
Contributor
Author
|
The ID is not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pcsx_rearmed is usable on old3ds, especially on some 2D games. However it goes unstable as soon as a savestate is loaded/saved. Turns out that due to large PSX savestates, the savestate undo buffers may eat something like 18MB out of ~42MB of RAM available to the core. When that happens the libctru variation in RetroArch tries to salvage memory from linear memory and/or stack, and when those are small or start overlapping with heap space things go real bad.
This PR proposes a way to disable the savestate undo feature from the core, as well as some other tweaks to reduce mem use in savestate code. See the individual commits for more explanation.
Related Issues
notaz/pcsx_rearmed#403 (on new3ds likely the same)