From 281955fb17bc34d321c85ad4b5a3bc4dc9a34e3a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 24 Jun 2026 18:38:37 +0000 Subject: [PATCH] fix: move cleanObservers to Tier 1 in MemoryTrimmingService cleanObservers() only removes flows not currently held by the UI, so it carries no visible side effects and is safe to run on every trim regardless of pressure level. Move it from Tier 3 (RUNNING_CRITICAL) to Tier 1 (always) so unused observer links are freed even on mild memory signals. Co-Authored-By: Claude --- .../amethyst/service/eventCache/MemoryTrimmingService.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/eventCache/MemoryTrimmingService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/eventCache/MemoryTrimmingService.kt index 9aa4dfab76..3501261a01 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/eventCache/MemoryTrimmingService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/eventCache/MemoryTrimmingService.kt @@ -53,8 +53,10 @@ class MemoryTrimmingService( otherAccounts: List, level: Int, ) { - // Tier 1: always run — cheap housekeeping + // Tier 1: always run — cheap housekeeping; cleanObservers only removes flows that are + // not currently held by the UI, so it is safe and inexpensive at any pressure level. cache.cleanMemory() + cache.cleanObservers() cache.pruneExpiredEvents() cache.prunePastVersionsOfReplaceables() @@ -66,8 +68,7 @@ class MemoryTrimmingService( } if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { - // Tier 3: critical pressure — sever observer links and drop muted content - cache.cleanObservers() + // Tier 3: critical pressure — drop muted content account.forEach { cache.pruneHiddenEvents(it) cache.pruneHiddenMessages(it)