Automatic Reference Counting releases Objective-C objects that have been allocated. What about primitive variables like char *
?
No as per the llvm document on ARC
Automatic Reference Counting implements automatic memory management for Objective-C objects and blocks, freeing the programmer from the need explicitly insert retains and releases. It does not provide a cycle collector; users must explicitly manage lifetime instead.
and
A retainable object pointer (or retainable pointer) is a value of a retainable object pointer type (retainable type). There are three kinds of retainable object pointer types:
- block pointers (formed by applying the caret (^) declarator sigil to a function type)
- Objective-C object pointers (id, Class, NSFoo*, etc.)
- typedefs marked with __attribute__((NSObject))
Other pointer types, such as int* and CFStringRef, are not subject to ARC's semantics and restrictions.
ARC directly release only ObjC objects (not char*
, void*
, int*
...). However ARC still calls the dealloc method of objects. So if you have an ObjC object that malloc's up some memory and points a char* at it, and the dealloc method calls free that memory will still get properly disposed of.
Same for Core Foundation objects, you still need to CFRelease
them. Even the toll free bridged CF types need manual calls to CFRelease
.
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