Neel Bakshi
Mar 28, 2021

--

I guess you're right, but I think it would depend on the size of the struct you're declaring. As far as I think how it works is that:

1. Structs whose size cannot be determined at compile time due to protocol or generic type associations are allocated on the heap.

2. Structs that might take up space more than that of a stack will have to reside in the heap.

Hope this helps! Lemme know if you find something as well 'cause I'm still searching as too !

EDIT — Found this talk — https://developer.apple.com/videos/play/wwdc2016/416/ which explains how protocols works. A must watch to understand memory implications of structs which implement a protocol.

--

--

Neel Bakshi

Guy who handles everything mobile @headout among other things! Ex @practo