<div dir="ltr"><span style="font-size:13px">I would like to suggest the following modification to the Mirror.DisplayStyle enum:</span><div style="font-size:13px"><br></div><div style="font-size:13px">for the Class case I would add an associated value of type ReferenceType (better naming is welcomed) which is yet another enum:</div><div style="font-size:13px"><br></div><div style="font-size:13px">enum ReferenceType {</div><div style="font-size:13px">    case Strong, Weak, Unowned</div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">enum Mirror.DisplayStyle {</div><div style="font-size:13px">...</div><div style="font-size:13px">   case Class(ReferenceType)</div><div style="font-size:13px">...</div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">This modification could assist in building better tools for detection of strong reference cycles which cause memory leaks.</div><div style="font-size:13px">The more general mathematical concept of a reference cycle is a &#39;strongly connected component&#39; or SCC.</div><div style="font-size:13px"><br></div><div style="font-size:13px">One possible tool could be an implementation of an algorithm to find all SCCs in a graph of all strong references discoverable from a certain working set (a set of immediately accessible references).</div><div style="font-size:13px">This algorithm can generate the following data:</div><div style="font-size:13px">1. count of SCC found (should be zero in order to avoid leaks)</div><div style="font-size:13px">2. size of largest SCC (size can be measured by either node count, edge count or the sum of both)</div><div style="font-size:13px">3. gather all objects of an SCC into an Array&lt;AnyObject&gt;</div><div style="font-size:13px">4. gather all strong references of an SCC into an Array&lt;(AnyObject, String)&gt; where a String would be a name of a stored property in the object.</div><div style="font-size:13px">Gathering this information periodically during a profiling session could potentially assist developers in detecting the formation of SCC and maybe even lead to finding the source of the problem.</div><div style="font-size:13px"><br></div><div style="font-size:13px"><br></div><div style="font-size:13px">The complexity of finding all SCC in a graph is O(m+n) time and space, where m is object count and n is count of all strong object references.</div><div style="font-size:13px">So this tool has performance impact and is not advisable to run on a production system.</div><div style="font-size:13px"><br></div></div>