<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=""><br class=""></div><div class="">There was a great talk at WWDC 2016 about internals and Swift performance. <a href="https://developer.apple.com/videos/play/wwdc2016/416/" class="">https://developer.apple.com/videos/play/wwdc2016/416/</a></div><div class=""><br class=""></div><div class="">At one point, Arnold Schwaighofer says, "Copying of large values incurs heap allocation.” What isn’t clear to me here is if he is still referring to just existential container types or in just large values in general.</div><div class=""><br class=""></div><div class="">My understanding is a value can get put on the heap if:</div><div class=""><br class=""></div><div class="">1) it is passed through a protocol and exceeds small size (3 words of storage)</div><div class="">2) it is captured by an escaping closure, and needs to extend lifetime</div><div class=""><br class=""></div><div class="">Suppose I make a large struct, and pass it as a parameter, is there a point where the compiler says, “Okay wise-guy, you are going on the heap now.” Can this be detected with MemoryLayout<BigStruct>.size? I have tried a couple experiments where I make beefy (1kB) structs in the playground but I never see the size suddenly dropping to a pointer size.</div><div class=""><br class=""></div><div class="">Any insights you have are greatly appreciated! 😃✨</div><div class=""><br class=""></div><div class="">Best wishes,</div><div class="">Ray</div><div class=""><br class=""></div><div class=""> </div></body></html>