From e17c95eda17dd979c97a0e418ca7e968a3893822 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 24 Jun 2026 21:35:14 +0000 Subject: [PATCH] fix: clear lastNotes on CardFeedContentState.trimToSize() to release Note refs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CardFeedContentState.lastNotes holds strong references to every raw Note that passed the notification filter, used for additive dedup (filteredNewList.minus(lastNotesCopy)). Trimming only the Card list left all those Note objects pinned — they couldn't be GC'd even if LocalCache's SoftCache had evicted them. Fix: clear lastNotes/lastAccount alongside the Card list truncation. The next additive update finds lastNotes == null, skips the fast path, and calls refreshSuspended() — one controlled rebuild from LocalCache that also resets the dedup set to the current state. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_019h2c44rAwexuUEP3kky2F3 --- .../screen/loggedIn/notifications/CardFeedContentState.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index aa88262e34..eb048e8bd1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -411,6 +411,13 @@ class CardFeedContentState( val loaded = current.feed.value if (loaded.list.size > maxItems) { current.feed.tryEmit(LoadedFeedState(loaded.list.take(maxItems).toImmutableList(), loaded.showHidden)) + // lastNotes holds strong refs to every raw Note that was ever included in this + // feed (used for additive-dedup). Clearing it releases those refs so the Notes + // are no longer pinned in memory independently of LocalCache. + // The next additive update will find lastNotes == null, skip the fast path, and + // call refreshSuspended() — a single controlled rebuild from LocalCache. + lastNotes = null + lastAccount = null } } }