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
Are bound Tweaks leaking the observation blocks? #53
Comments
That's absolutely true. We're not using this API ourselves at the moment so I never noticed it. You |
Please consider using RxSwift instead of ReactiveCocoa |
Uhm why, and what does that have to do with this repo? :) |
Thanks for finding this @mac-cain13! |
I was considering creating an RxSwiftCommunity project that allowed RxSwift compatibility with SwiftTweaks. There are many good reasons to favour RxSwift over ReactiveCocoa. Your comment gave me the impression you were interested in providing an industry-standard reactive framework in which to base your binding implementation. |
I'm sorry but that's A: unfounded, and B: completely irrelevant to this issue and to the library.
My comment was giving an example of how one could implement this (I mentioned |
(I know this is an old thread, but it's still an open issue, so I figured I'd add a comment here.) I've intentionally avoided adding ReactiveCocoa or RxSwift to the project, so that SwiftTweaks stays simple for anybody to understand! We use ReactiveCocoa in the Khan Academy iOS app, so it's familiar to us, but that doesn't mean everybody should have to understand it / use it to understand and contribute to SwiftTweaks. @mac-cain13, thank you for pointing out this bug! I don't have an immediate solution in mind, but definitely open for discussion again. Thanks! |
At the top of my mind I can think of two options (both already discussed above):
I think option 1 would be better since it isn't a breaking change and fixes the issue without losing functionality. |
@mac-cain13 I agree - option 1 sounds great for this. |
This is a real improvement - thanks! |
Alright, this thing should be closed now - we've got binding tokens in there 😄 |
We're using SwiftTweaks in a project and while using
bind
for a few Tweaks I was wondering when those observer closures are released. I skimmed through the source code and it appears to me that the closure given tobind
is saved in a dictionary where it is strongly references forever.If I'm not mistaken these bindings dictionaries are never cleaned up neither there is any API to unregister the binding. So everytime my ViewController is started I
bind
a new closure that will be around forever, this looks like a memory leak to me.Is there anything I'm missing that resolved this memory issue? Or is this an issue and do we need to add some kind of
unbind
call to remove the closure from the list.The text was updated successfully, but these errors were encountered: