3 ms·
Well, be careful with that. A lot of properties in Cocoa and Cocoa Touch are not retained automatically (delegates, data sources and so on). If you just autorel
by DrJokepu 15y ago
Well, be careful with that. A lot of properties in Cocoa and Cocoa Touch are not retained automatically (delegates, data sources and so on). If you just autorelease them you will have problems.
The other reason people are careful about autoreleases is because, obviously, objects in the autorelease pool won't get deallocated until the pool is drained, which normally happens in the main application loop. Normally, this is not a problem, but if you do memory-intensive things (like dealing with images or other media) in a loop that means that you will consume a lot of memory before the autorelease pool gets drained. This might get other apps killed (on iOS 4+), and ultimately, yours too.
- danudey 15y agoThe other problem with autorelease is when you release too many times; the autorelease pool gets drained down the road, and your app crashes in some other situation (inconsistently) at a time unrelated to when you made the mistake.