<div dir="ltr">I reported this about a year ago, but it has never been fixed and it seems like it should be fixed for the Swift 4.0 release.<div><br></div><div>Here is a simple repro case. If you watch the memory monitor as it runs, you see memory consumption climb to 2.7GB when using #function, and no memory increase when using a static string.</div><div><br></div><div><div>import Foundation</div><div><br></div><div>class A {</div><div><span style="white-space:pre">        </span>var counter = 0 {</div><div>//<span style="white-space:pre">                </span>didSet { onSet(&quot;counter&quot;) }  // no leak</div><div><span style="white-space:pre">                </span>didSet { onSet() }  // huge leak</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>var properties = [&quot;counter&quot; : 0]</div><div><span style="white-space:pre">        </span>func onSet(_ name: String = #function) {</div><div><span style="white-space:pre">                </span>properties[name]! += 1</div><div><span style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div>var myclass = A()</div><div><br></div><div>for i in 0..&lt;10000000 {</div><div><span style="white-space:pre">        </span>myclass.counter = i</div><div>}</div><div><br></div><div>print(myclass.properties[&quot;counter&quot;]!)</div></div><div><br></div></div>