What exactly does the Objective-C garbage collector collect? For example, if I’m writing a program in Objective-C 2.0, and I use some plain C structs, does my code need to worry about manually freeing that memory?
What exactly does the Objective-C garbage collector collect? For example, if I’m writing a
Share
For heap memory, you’re on your own by default. Unless you allocate heap memory with
NSAllocateCollectableorNSReallocateCollectable, or explicitly hand a CoreFoundation object over to the garbage collector via an API likeNSMakeCollectable, the GC has no idea about your memory, and won’t manage it for you. Conversely, when GC is enabled, Objective-C objects created with+alloc/-initare managed by GC unless you explicitly tell it otherwise with a complementary API call.http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/