Skip to content

Fix memory leak: return early on image cache hit in MessageImageView#92

Closed
beezly wants to merge 8 commits intoviktorstrate:mainfrom
beezly:fix/image-cache-memory-leak
Closed

Fix memory leak: return early on image cache hit in MessageImageView#92
beezly wants to merge 8 commits intoviktorstrate:mainfrom
beezly:fix/image-cache-memory-leak

Conversation

@beezly
Copy link
Copy Markdown
Contributor

@beezly beezly commented Apr 7, 2026

Summary

  • MessageImageView's .task block checked NSCache on cache hit but never returned, causing getMediaContent to be called on every channel visit even for already-cached images
  • Adds the missing return after a cache hit — a one-line fix matching the pattern already used in MatrixImageView and AvatarImage
  • Verified with OSLog debug instrumentation: before the fix, every return to a channel showed cache HIT immediately followed by a redundant network fetch; after the fix, cache hits return early with no network call

Test plan

  • Navigate to a channel with images and note memory usage
  • Switch to another channel and back — memory should no longer increase for already-loaded images
  • First load of an image still fetches from network (cache miss path unchanged)

Fixes #89

@beezly
Copy link
Copy Markdown
Contributor Author

beezly commented Apr 7, 2026

Superseded by a clean branch based on origin/main — see new PR.

@beezly beezly closed this Apr 7, 2026
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.

Memory leak when loading timelines.

1 participant