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 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-24 20:11:27 +00:00
parent f038e54fa2
commit 281955fb17
@@ -53,8 +53,10 @@ class MemoryTrimmingService(
otherAccounts: List<AccountInfo>,
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)