-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Previous ID | SR-4893 |
Radar | None |
Original Reporter | jholliday (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Duplicate |
Attachment: Download
Additional Detail from JIRA
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: b58edaf47ba3c477f8bf84f483270539
duplicates:
- 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 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.