You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-3805 Creating a strong reference to self in a closure should warn if self is never accessed "strongly"
Issue Description:
When declaring a closure, it's unclear to me what scope the strong reference to self is pulled from. When hunting for a leak, I discovered that my [weak self] declaration at the beginning of a closure caused a strong reference from the encompassing scope, which caused a leak.
I'm attaching a sample project that I can reproduce the leak with. Hitting the bar button item in the upper right will push a view controller on the stack that never gets cleaned up because it has a retain cycle.
The text was updated successfully, but these errors were encountered:
Just to clarify a bit - when I looked at this, I figured it's because self gets captured in the context that is declaring the closure. I found this to be confusing (but not bugged) because it meant that the declaration of weak self, which is written within the curly braces of the closure, retains it outside that scope.
Attachment: Download
Additional Detail from JIRA
md5: b58edaf47ba3c477f8bf84f483270539
duplicates:
Issue Description:
When declaring a closure, it's unclear to me what scope the strong reference to self is pulled from. When hunting for a leak, I discovered that my [weak self] declaration at the beginning of a closure caused a strong reference from the encompassing scope, which caused a leak.
I asked Joe about this on Twitter, and he said
"To me, that seems like a language bug. We should capture self weakly transitively through the outer closure."
For more context: https://twitter.com/jckarter/status/864165194783535104
I'm attaching a sample project that I can reproduce the leak with. Hitting the bar button item in the upper right will push a view controller on the stack that never gets cleaned up because it has a retain cycle.
The text was updated successfully, but these errors were encountered: