Hey, I'm trying to tie my DI graphs to UI, and I s...
# compose
u
Hey, I'm trying to tie my DI graphs to UI, and I switch which is active with
AnimatedContent
as to get nice animated transition switch But just for funsies I wanted to check if the switched-away instances do get GC'ed as expected, and turns out they don't (?). And when I switch
AnimatedContent
to simple
when
then it's all fine. So I dumped heap and I'm still seeing my objects referenced via some compose machinery, way after the transition happened (like 10 seconds) Is there a known memory leak in latest
AnimatedContent
? The code is bog standard
Copy code
val appState by appRootStateHelper.state.collectAsState()
AnimatedContent(
    targetState = appState,
) {
    when (it) {
        is AppRootState.Subscriber -> {
            SubscriberRoot(it.subscriberGraph)
        }
        ...
    }
}
Or is this somehow weirdly expected? That previous states are kept in
Transition
forever??
s
Can you file a bug with a repro for this? That should not happen.
u
Can you first pls confirm that AnimatedContent is not supposee to hold onto previous state after animation is finished? I was getting conflicting info on the internets
s
No it shouldn't afaict
did I get the tracker right?
btw maybe you could help push a long my other report which we discussed some time ago issuetracker.google.com/issues/506393888 it went dark, and the bug is still there, making
retain
-ed objects subar relative to
ViewModel
which doesnt seem to have this bug; and I don't want to build my presenter api on top of androidx
ViewModel
if I can help it
s
i think it is assigned as something to fix, will check with the assignee later
u
thank you