Repository navigation
Return freed large blocks to the system at once - #20
Merged
Merged
Conversation
With 0.2.9's zoomed-out drawing the RG DS's memory varied from run to run (336-371 MiB in minutes 1-6). It was native memory glibc kept after it was freed: after a large block is freed, glibc raises the size it takes directly from the system, so later large temporary buffers (sprite decoding, the graphics driver's texture copies) stayed in the heap. The launcher now sets MALLOC_MMAP_THRESHOLD_=262144 unless it is already set. Same zoom round on the published 0.2.9 archive: RG DS 329-342 MiB (two runs), RG34XXSP 257-274 (was 300-353), park still 59-60 FPS in warm minutes. The device report lists the variable; a launcher test checks both allocator defaults and that a user's own values are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes the open item 0.2.9 shipped with: on the RG DS, memory with the zoomed-out park varied from run to run.
What it was
malloc_trimonce a minute (tried, not kept) gave back 20–33 MiB each time, and the memory refilled within the minute. So glibc was keeping freed native memory.The change
launch.shsetsMALLOC_MMAP_THRESHOLD_=262144unless it is already set, next to the existingMALLOC_ARENA_MAX=2. Blocks over 256 KiB then go back to the system as soon as they are freed. The device report lists the variable, and a new launcher scenario checks both allocator defaults and that a user's own values are kept.Results (same 400 s zoom round, published 0.2.9 archive, the setting passed in by the QA tool)
Then a clean package of this commit on both handhelds (80 s park + Pokéwalker):
pkforge-report.txtshows the launcher setMALLOC_MMAP_THRESHOLD_=262144. Both runs ended cleanly with no problems reported and userdata unchanged; peak memory was 316 MiB on the RG DS and 262 on the RG34XXSP.Verification
sh -nonlaunch.sh.build.ps1+verify-package.ps1on the clean commit.🤖 Generated with Claude Code