<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="">
Wow. Thanks for the info. I am indeed seeing the leak on the iPad but not in the simulator. Same with your code. I am using the newest Xcode 8.2.1 (8C1002)<br class="">
<div class="">Please keep me posted and I’ll do the same.</div>
<div class="">Thanks!</div>
<div class="">Chris<br class="">
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Dec 20, 2016, at 2:02 AM, Ray Fix <<a href="mailto:rayfix@gmail.com" class="">rayfix@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">Thanks for the update Chris. 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 Version 8.2 (8C38). 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! )</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;" 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=""> </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=""> </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=""> </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=""> </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=""> }</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=""> </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=""> </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=""> </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;" class=""> </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" 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;" 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=""> }</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<String, Thing> 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<String, Thing> 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=""><span id="cid:7157435C-A940-4357-807B-47FF6591AE85"><Screen Shot 2016-12-19 at 4.53.03 PM.png></span></div>
<div class=""><br class="">
</div>
<br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Dec 17, 2016, at 12:12 AM, Chris Chirogene <<a href="mailto:cchiroge@adobe.com" class="">cchiroge@adobe.com</a>> 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 <<a href="mailto:rayfix@gmail.com" class="">rayfix@gmail.com</a>> wrote:<br class="">
<br class="">
FWIW, seeing this too. Also, when I boiled the project down to a macOS command line and run the “leaks" cli I don’t see the leak. 🤔 <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 <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> 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="">
import Foundation<br class="">
<br class="">
class Test: NSObject // <-- derived from NSObject produces leak indication below<br class="">
{<br class="">
static var cTest: Test! = nil<br class="">
var mDict: [String : Test] = Dictionary<String, Test>()<br class="">
<br class="">
static func test() -> Void {<br class="">
cTest = Test()<br class="">
cTest.mDict["test"] = Test() // <-- alleged leak<br class="">
}<br class="">
}<br class="">
<br class="">
class Test // <-- NOT derived from NSObject, NO leak indication<br class="">
{<br class="">
static var cTest: Test! = nil<br class="">
var mDict: [String : Test] = Dictionary<String, Test>()<br class="">
<br class="">
static func test() -> Void {<br class="">
cTest = Test()<br class="">
cTest.mDict["test"] = Test() // <-- NO leak<br class="">
}<br class="">
}<br class="">
<br class="">
// from AppDelegate didFinishLaunchingWithOptions<br class="">
// ...<br class="">
Test.test()<br class="">
// ...<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="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</blockquote>
<br class="">
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>