Skip to content

perf: downsampled thumbnails cut Snappilot's memory use - #4

Open
iamrraj wants to merge 1 commit into
mainfrom
fix/thumbnail-memory
Open

iamrraj wants to merge 1 commit into
mainfrom
fix/thumbnail-memory

Conversation

@iamrraj

@iamrraj iamrraj commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Snappilot measured 848 MB footprint after 2 days, 435 MB of it decoded images: every preview tile decoded the full-resolution screenshot (about 15 MB per tile) and kept it.

This loads tile-sized thumbnails off the main thread into a cache capped at 120 MB, releases off-screen tiles, fixes collection covers decoding in body, uses tile-sized video frames, frees images per item in batch export, and caps editor undo at 50 steps.

Measured

  • 40-tile grid of real captures: +621 MB → +95 MB (3 runs each)
  • Fresh launch to the dashboard: ~160 MB → ~120 MB, with no decoded-image memory left

Tests: 6 new snapverify checks for thumbnail sizing and failure cases; the full suite passes.

Note: CI on main also needs #3 (older-Xcode build fix) merged to go green.

Every preview tile (library and dashboard gallery, collection covers, PDF
and batch pickers, the editor's Recent tray, video previews) decoded the
full-resolution capture, about 15 MB per tile once on screen, and kept it
for the life of the view. A 2-day-old process measured 848 MB footprint,
435 MB of it ImageIO.

- Thumbnail.make decodes straight to the tile size with ImageIO.
- ThumbnailCache loads previews off the main thread into an NSCache
  capped at 120 MB; tiles drop their image when scrolled off screen so
  the cap actually frees memory.
- Collection covers no longer decode an image inside body.
- Video previews request a tile-sized frame.
- Editing a capture invalidates its cached preview.
- Batch export releases each full-size image before the next.
- Editor undo history is capped at 50 steps (each can hold a full image).

Measured: a 40-tile grid of real captures went from +621 MB to +95 MB
(3 runs each); fresh launch to the dashboard went from ~160 MB to ~120 MB
with no decoded-image memory left.
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