Unowned references have more overhead than strong references?

I've not stayed totally on top of the details here but I should have been more specific--the "like weak but guaranteed to crash" is only true at the conceptual level. IIRC at the implementation level, unowned doesn't do the same side table shenanigans as weak, and instead uses the zombie object approach that weak references did pre-Swift-4 (since unowned references aren't supposed to outlive the referenced object). That is, we track both the strong reference count and the unowned reference count, and we don't deallocate memory until the both the strong and unowned count go to zero. So unowned(safe) and strong references both do RC and point directly at the object.

2 Likes