I'm profiling my Swift iOS app using Instruments. A bunch of time is spent in
_swift_retain_(swift::HeapObject*) libSwiftCore.dylib
and
_swift_release_(swift::HeapObject*) libSwiftCore.dylib
My code is mostly creating (and going out of scope) structs and tuples. It's my understand that since they are value objects, they're allocated on the stack, thus I shouldn't be seeing so much heap action.
What exact does _swift_retain_
and _swift_release_
mean?
These functions _swift_retain_
and _swift_release_
are part of Swifts automatic reference counting (ARC). For detailes, see the source in stdlib. ARC seems to be quite often nagged upon w.r.t. performance issues such as this one, but I'm surprised you see this behaviour using only value types. However, possibly this is due to something with ARC behind the hood.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With