<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="">I definitely concur that tools like Instruments are the best way to understand the impact of decisions on memory across the board. &nbsp;For fine-grained inquiries about memory use you can also rely on malloc family functions to make inquiries:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">let required_size = malloc_size(unsafeAddressOf(<i class="">object_reference</i>))</div><div class="">let actual_size = malloc_good_size(required_size)</div></blockquote><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="" style="font-family: LucidaGrande; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><font color="#424242" class="" style="font-family: 'Lucida Grande'; font-size: x-small;">Kate Stone</font><span class="" style="font-family: 'Lucida Grande'; font-size: x-small;">&nbsp;</span><font color="#009193" class="" style="font-family: 'Lucida Grande'; font-size: x-small;"><a href="mailto:k8stone@apple.com" class="">k8stone@apple.com</a></font></div><div class="" style="font-family: Times; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><font face="Lucida Grande" size="1" class=""><font color="#009193" class=""></font>&nbsp;Xcode&nbsp;<font color="#424242" class="">Low Level Tools</font></font></div></div></div></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Mar 23, 2016, at 3:59 PM, Howard Lovatt via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks, I will give that a try</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature">&nbsp; -- Howard.<br class=""></div></div>
<br class=""><div class="gmail_quote">On 24 March 2016 at 03:17, Jens Alfke <span dir="ltr" class="">&lt;<a href="mailto:jens@mooseyard.com" target="_blank" class="">jens@mooseyard.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 22, 2016, at 11:04 PM, Howard Lovatt via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family:Alegreya-Regular;font-size:15px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">I am writing custom collection classes and trying to assess which one is better, both in terms of performance and memory usage. Won't be used in 'real' code, just to guide development.</div></div></blockquote></div><br class=""><div class="">You might consider using heap profiling tools too, like (on Mac OS) the Instruments app or the `heap` command-line tool. If you use these while running a benchmark app using your API, it can show you how much total heap space gets used.</div><div class=""><br class=""></div><div class="">Actual heap usage can differ from the raw “sizeof” a data type, since allocators will often round up block sizes or return a somewhat larger block than necessary. Heap fragmentation can also increase memory usage beyond what you’d expect, and different allocation patterns can affect fragmentation.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">—Jens</div></font></span></div></blockquote></div><br class=""></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=""></div></body></html>