Does existential containers use Copy on Write in Swift?

Viewed 53

I am considering use cases of both generics and protocol type in Swift.

The disadvantage of protocol type is heap allocation when the target is large memory footprint.

I want to avoid heap allocation for each function call, whose arguments include protocol type, in general. However, if existential containers use Copy on Write, heap allocation must not occur unless inout.

Does heap allocation occur when you call a function whose arguments include protocol type or not?

Thanks.

0 Answers
Related