<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks for the update Chris. &nbsp;Hmm...</div><div class=""><br class=""></div><div class="">So, I get memory runtime issues if I run this on an actual device iPad Air 2 (iOS 10.2) with&nbsp;Version 8.2 (8C38). &nbsp;Can’t get it to happen on the simulator. Can’t get it to happen if I make a macOS command line tool and inspect it with the leaks command.</div><div class=""><br class=""></div><div class="">(I reported this as radar 29715025 but if anyone has any insights please share! &nbsp;)</div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Ray Fix</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="font-family: 'Apple Color Emoji'; font-size: 20px;" class="">😄</span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">import</span><span style="font-variant-ligatures: no-common-ligatures" class=""> UIKit</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Thing {}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Test: </span><span style="font-variant-ligatures: no-common-ligatures" class="">NSObject</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">static</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> shared = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Test</span><span style="font-variant-ligatures: no-common-ligatures" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> dictionary: [</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Thing</span><span style="font-variant-ligatures: no-common-ligatures" class="">] = [:]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> method() {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">dictionary</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"value"</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Thing</span><span style="font-variant-ligatures: no-common-ligatures" class="">()]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ViewController: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIViewController</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">override</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> viewDidLoad() {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">super</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">viewDidLoad</span><span style="font-variant-ligatures: no-common-ligatures" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Test</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">shared</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">method</span><span style="font-variant-ligatures: no-common-ligatures" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"Leaky leaky... click on the memory visualizer to see issues."</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><br class=""></div><div class="">When I click the memory visualizer it shows:</div><div class=""><br class=""></div><div class=""><div class="">Memory Issues – (3 leaked types) Group</div><div class="">runtime: Memory Issues – (3 leaked types): 1 instance of _NativeDictionaryStorageImpl&lt;String, Thing&gt; leaked</div><div class=""><a href="x-xcode-debug-memory-graph://7fa607cb92c0/4296:" class="">x-xcode-debug-memory-graph://7fa607cb92c0/4296:</a> runtime: Memory Issues: 0x1700f9f80</div><div class="">runtime: Memory Issues – (3 leaked types): 1 instance of _NativeDictionaryStorageOwner&lt;String, Thing&gt; leaked</div><div class=""><a href="x-xcode-debug-memory-graph://7fa607cb92c0/5924:" class="">x-xcode-debug-memory-graph://7fa607cb92c0/5924:</a> runtime: Memory Issues: 0x170271dc0</div><div class="">runtime: Memory Issues – (3 leaked types): 1 instance of Thing leaked</div><div class=""><a href="x-xcode-debug-memory-graph://7fa607cb92c0/1891:" class="">x-xcode-debug-memory-graph://7fa607cb92c0/1891:</a> runtime: Memory Issues: 0x170019ca0</div></div><div class=""><br class=""></div><div class=""><img apple-inline="yes" id="ADA85C54-99F6-426B-B0E5-66682249FA73" height="480" width="640" apple-width="yes" apple-height="yes" src="cid:7157435C-A940-4357-807B-47FF6591AE85" class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 17, 2016, at 12:12 AM, Chris Chirogene &lt;<a href="mailto:cchiroge@adobe.com" class="">cchiroge@adobe.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Interesting. Thanks. I’ll have to try that.<br class="">The latest Xcode 8.2 release version seems to have fixed this. I am no longer seeing the leak.<br class="">Take care,<br class="">Chris<br class=""><br class=""><blockquote type="cite" class="">On 17 Dec 2016, at 02:33, Ray Fix &lt;<a href="mailto:rayfix@gmail.com" class="">rayfix@gmail.com</a>&gt; wrote:<br class=""><br class="">FWIW, seeing this too. &nbsp;Also, when I boiled the project down to a macOS command line and run the “leaks" cli I don’t see the leak. 🤔 &nbsp;<br class=""><br class="">Ray<br class=""><br class=""><blockquote type="cite" class="">On Oct 14, 2016, at 9:42 AM, Chris Chirogene via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">Xcode8 is showing a memory leak in instruments and the memory graph. I have narrowed it down to this: deriving from NSObject produces a leak indication. I have no idea why.<br class="">I need an NSObject to later use the @objc directive.<br class="">The Test instance stored in the mDict Dictionary is indicated as a leak in Xcode.<br class="">This is running as an iOS Single-View-Application project in the iPhone5s Simulator running iOS10.0<br class="">Here is the sample code:<br class=""><br class=""> &nbsp;import Foundation<br class=""><br class=""> &nbsp;class Test: NSObject &nbsp;// &lt;-- derived from NSObject produces leak indication below<br class=""> &nbsp;{<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static var cTest: Test! = nil<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var mDict: [String : Test] = Dictionary&lt;String, Test&gt;()<br class=""><br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static func test() -&gt; Void {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cTest = Test()<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cTest.mDict["test"] = Test() // &lt;-- alleged leak<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;}<br class=""><br class=""> &nbsp;class Test &nbsp;// &lt;-- NOT derived from NSObject, NO leak indication<br class=""> &nbsp;{<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static var cTest: Test! = nil<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var mDict: [String : Test] = Dictionary&lt;String, Test&gt;()<br class=""><br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static func test() -&gt; Void {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cTest = Test()<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cTest.mDict["test"] = Test() // &lt;-- NO leak<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;}<br class=""><br class=""> &nbsp;// from AppDelegate didFinishLaunchingWithOptions<br class=""> &nbsp;// ...<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test.test()<br class=""> &nbsp;// ...<br class=""><br class="">_______________________________________________<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=""></blockquote><br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></body></html>