Skip to content

Fix framebuffer image memory retention#242

Merged
mariusandra merged 1 commit into
mainfrom
codex/fix-framebuffer-image-memory
Jun 26, 2026
Merged

Fix framebuffer image memory retention#242
mariusandra merged 1 commit into
mainfrom
codex/fix-framebuffer-image-memory

Conversation

@mariusandra

Copy link
Copy Markdown
Collaborator

Summary

Fixes framebuffer frames retaining high RSS after rendering large local photos.

  • Clear transient render/image source image fields after run and get.
  • Drop the final rotated render image reference after driver render.
  • On framebuffer devices, force Nim collection and call Linux malloc_trim(0) after each draw so freed decode/scale memory can return to the OS.
  • Add render/image tests that assert transient image fields are cleared.

Root Cause

The local image scene decodes full-size photos before scaling them to the framebuffer. On HDMI framebuffer targets with the Pixie engine, large decoded source images and allocator high-water memory could keep process RSS near the systemd memory limit after each render. Later large images then pushed frameos into OOM. E-ink devices were less affected because their render cadence/path differs.

Impact

Framebuffer frames that cycle through large local images should return to a lower memory baseline after each render instead of gradually sitting near MemoryMax. The forced reclamation is scoped to device == "framebuffer" to avoid adding GC work to other driver paths.

Validation

  • nim c -r src/apps/render/image/tests/test_app.nim
  • nim c -r src/apps/data/localImage/tests/test_app.nim
  • nim c -r src/frameos/tests/test_runner_loop.nim
  • nim check --os:linux src/frameos/utils/memory.nim
  • nim c --compileOnly -d:malloc --nimcache:.nimcache/frameos_check_malloc src/frameos.nim

@mariusandra mariusandra marked this pull request as ready for review June 26, 2026 18:29
@mariusandra mariusandra changed the title [codex] Fix framebuffer image memory retention Fix framebuffer image memory retention Jun 26, 2026
@mariusandra mariusandra merged commit c5d837a into main Jun 26, 2026
35 checks passed
@mariusandra mariusandra deleted the codex/fix-framebuffer-image-memory branch June 26, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant