New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StackState/StackReducer related leak #2508
Comments
Hi @bioche, are you certain it is an issue in TCA and not that SwiftUI is holding onto the I ran your sample project in Xcode 15 with the iOS 17 simulator and I do not see any leaks in the memory graph debugger. Perhaps it was fixed in iOS 17? |
Thanks @mbrandonw for the quick response ! I'm not sure it's SwiftUI as when using the "present stack using TCA" that uses the same views but with a MainCore that has a ifLet reducer it works with no leak. Also I forgot to mention in the bug report that if I comment those 2 effects in the I reproduce it on iOS 17 simulator on my side : |
Reopening with #2648. We will be able to fix this eventually, but for now there is a small cycle that in breaking can prevent certain effects from making it back into the system. |
Description
For the last 2 days I'v been trying to understand a leak & I have been able to reproduce it in this sample project : NavigationStackLeak.zip
The issue occurs when creating a
StoreOf<FlowCore>
from scratch, whereFlowCore
is a Reducer wrapping aStackState
/StackAction
combined using forEach operator.It seems like pushing a node in
StackState
causes effects to be added by_StackReducer
that will causeStore
& all its properties to not being deallocated once theNavigationStack
gets dismissed causing a leakThanks in advance for looking into this :)
Checklist
main
branch of this package.Expected behavior
I would expect Store to be removed from memory once the view/controller using them has been dismissed
Actual behavior
Stores are stacking up after each present/dismiss of FlowView
Steps to reproduce
FlowCore
: you will see as many instance ofStoreOf<FlowCore>
as modal openedIt's important to note that the issue is not there when
FlowCore
is embedded in another Reducer likeMainCore
in example project (try same scenario using "present stack using TCA" button instead). probably because effects built in_StackReducer
get properly cancelled in that case.A quick fix on my side would be to send action to pop all nodes of
StackState
when receiving dismiss action. However a fix on the lib would be preferable as others could stumble upon this issue & like me waste hours trying to figure out what is happening ;)The Composable Architecture version information
0.59.0 / 1.2.0 / main branch
Destination operating system
iOS 16.2
Xcode version information
XCode 14.2
Swift Compiler version information
The text was updated successfully, but these errors were encountered: