<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On Mar 4, 2017, at 11:35 AM, Charles Srstka via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><blockquote type="cite" class="">On Mar 4, 2017, at 1:09 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I encountered this precise memory leak in my code a few days ago, so I sympathize. A second solution would be to drop function references. I think a core team member suggested it on another thread.</span></div></blockquote></div><br class=""><div class="">If I had to guess, I’d surmise that it's probably the single most common memory leak in Swift and modern Objective-C code. What I wish is that it were possible to get rid of implicit captures altogether—instead of just inserting [weak self] when you *don’t* want to capture something strongly, also require [strong self] when you do. Referencing self otherwise causes an error. We’d never get away with it now, though, with the source compatibility promise in place.</div></div></blockquote><div><br></div>Have you seen my guarded closures proposal? I'm planning to update that to incorporate some additional ideas as soon as I have time. I'm hoping I can get to this soon and have it reviews for Swift 4. I think it would help address this problem without breaking compatibility.<div><br><blockquote type="cite"><div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></body></html>