fix(spruce): Prevent OOM during ROM cache population - #263
Merged
BrandonKowalski merged 1 commit intoAug 16, 2026
Conversation
boburning
marked this pull request as ready for review
August 15, 2026 10:11
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.
What changed
Why
fetchPlatformGamespreviously preallocated a slice for a platform's complete ROM count and appended every API page before writing to SQLite. Responses include nested file and metadata payloads, so large libraries can exhaust 128 MB handhelds during the initial background cache sync.On a Miyoo Mini Plus running spruceOS, the official ARM32 build exited after 23 seconds while fetching a 1,314-ROM FinalBurn Neo platform. Grout reached about 65 MB RSS immediately before disappearing; the device has about 100 MB usable RAM and no swap.
Page-sized transactions bound the retained response and database batching working set while preserving full and incremental update behavior.
SavePlatformGamesalready replaces rows per game, so committing individual pages is compatible with both paths.Device validation
Built the patched ARMv7 binary with the repository's
docker/32.Dockerfileand tested it on the same Miyoo Mini Plus with swap disabled.Cache population completedandBackgroundSync: Sync completedChecks
go test ./cachegofmton changed Go filesgit diff --checkdocker/32.Dockerfile