Merge pull request #2527 from vitorpamplona/claude/remove-group-on-leave-JTVQb

Fix memory leak when leaving Marmot groups
This commit is contained in:
Vitor Pamplona
2026-04-23 12:12:37 -04:00
committed by GitHub
4 changed files with 31 additions and 2 deletions
@@ -2319,6 +2319,12 @@ class Account(
}
val outbound = manager.leaveGroup(nostrGroupId)
// manager.leaveGroup already wiped MLS state, relay subscriptions and
// the persisted message log. Drop the in-memory chatroom too — that
// releases the strong refs to the decrypted inner notes so LocalCache
// (which holds them weakly) can GC them, and the Notification feed
// (which iterates marmotGroupList.rooms) stops surfacing the group.
marmotGroupList.removeGroup(nostrGroupId)
client.publish(outbound.signedEvent, groupRelays)
}
@@ -316,7 +316,6 @@ fun MarmotGroupInfoScreen(
scope.launch(Dispatchers.IO) {
try {
accountViewModel.leaveMarmotGroup(nostrGroupId)
accountViewModel.account.marmotGroupList.removeGroup(nostrGroupId)
nav.nav(Route.Message)
} catch (e: Exception) {
isLeaving = false