<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi, jemmons. I managed to reproduce this in pure Swift code, and then changed it so that the Swift dictionary got released. In the latter version, no leaks were reported, so I think it's just a problem with our tools. (This isn't too surprising; the internals of a Swift Dictionary use some of the known-zero bits in the storage pointer to store flags, like "this dictionary came from Cocoa".)</div><div class=""><br class=""></div><div class="">I'ne filed a bug report with the Instruments team. Thanks for bringing this up!</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 21, 2016, at 13:36 , Joshua Scott Emmons via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Say you have something like the following (or just grab the attached project: <a href="https://dl.dropboxusercontent.com/u/364098/DictionaryLeak.zip" class="">https://dl.dropboxusercontent.com/u/364098/DictionaryLeak.zip</a>)<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: 'Source Code Pro'; color: rgb(129, 144, 144);" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="color: rgb(71, 91, 98); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class="">//SwiftModel.swift</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">class</span> SwiftModel : <span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">NSObject</span> {</span></div><div style="color: rgb(41, 161, 152); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> prop: [</span>NSObject<span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">:</span>AnyObject<span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">]</span></span></div><div style="color: rgb(41, 161, 152); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">init</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">(dict: [</span>NSObject<span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">:</span>AnyObject<span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">]){</span></span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #595ab7" class="">prop</span> = dict</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""> }</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class="">}</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="color: rgb(71, 91, 98); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class="">//MyViewController.m</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class="">- (<span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">void</span>)viewDidLoad {</span></div><div style="color: rgb(39, 139, 210); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">super</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> </span>viewDidLoad<span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">];</span></span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal; min-height: 23px;" class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div style="color: rgb(71, 91, 98); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">NSDictionary</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> *dict = </span><span style="font-variant-ligatures: no-common-ligatures; color: #dc322f" class="">@{</span><span style="font-variant-ligatures: no-common-ligatures; color: #bd3613" class="">@"Thing"</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class=""> : </span><span style="font-variant-ligatures: no-common-ligatures; color: #bd3613" class="">@"Stuff"</span><span style="font-variant-ligatures: no-common-ligatures; color: #dc322f" class="">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #819090" class="">; //Leaks!</span></span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">SwiftModel</span> *model = [[<span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">SwiftModel</span> <span style="font-variant-ligatures: no-common-ligatures; color: #278bd2" class="">alloc</span>] <span style="font-variant-ligatures: no-common-ligatures; color: #278bd2" class="">initWithDict</span>:dict];</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""> [<span style="font-variant-ligatures: no-common-ligatures; color: #c6226f" class="">self</span> <span style="font-variant-ligatures: no-common-ligatures; color: #2176c7" class="">setSwiftModel</span>: model];</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class="">}</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal; min-height: 23px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 23px;" class=""><span style="font-family: Helvetica;" class="">Running this in Instruments (</span>Xcode 7.2 7C68) <span style="font-family: Helvetica;" class="">reports a leak:</span></div><div style="color: rgb(129, 144, 144); font-family: 'Source Code Pro'; margin: 0px; line-height: normal; min-height: 23px;" class=""><span id="cid:A5A3FDD6-7329-4943-A284-F571A47FEC7B@reverb.internal"><Screen Shot 2016-01-21 at 3.27.47 PM.png></span></div><div style="margin: 0px; line-height: normal; min-height: 23px;" class="">Is this actually leaking? Or is this just Instruments loosing track of what's actually holding on to the NSDictionary once it's bridged to swift-world?</div><div style="margin: 0px; line-height: normal; min-height: 23px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 23px;" class="">Or am I completely overlooking some important concepts somewhere along the line? :) </div><div style="margin: 0px; line-height: normal; min-height: 23px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 23px;" class="">Cheers,</div><div style="margin: 0px; line-height: normal; min-height: 23px;" class="">-jemmons</div></div></div></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>