4 ms·
Autorelease isn't a silver bullet for Obj-C memory management. There are a number of cases in which you would NOT want to autorelease objects - tight loops, for
by Aqua_Geek 15y ago
Autorelease isn't a silver bullet for Obj-C memory management. There are a number of cases in which you would NOT want to autorelease objects - tight loops, for example.
If you're already in the habit of autoreleasing everything you +alloc, why not just release it when you're done with it instead?
- Hisoka 15y agobecause like I said it's easy to forget when to do that. Example UIView* view = [[UIView alloc] init]; ...do a bunch of stuff [view release] <-- you have to remember this vs. UIView* view = [[[UIView alloc] init] autorelease]; Of course I know about the cases where we have tight loops,w hich is why i said 99 of the time.
- marcomonteiro 15y agoPersonally I only use autorelease when I create an object I'm not responsible for. For example, if I create a view somewhere for another object to utilize. I also like knowing that as soon as I'm done with an object that it gets killed and the system can reclaim the memory.