Re: Some really simple release/autoRlease questions
Re: Some really simple release/autoRlease questions
- Subject: Re: Some really simple release/autoRlease questions
- From: Krevnik <email@hidden>
- Date: Sat, 15 Mar 2003 14:17:29 -0800
On Saturday, March 15, 2003, at 02:05 PM, Jeffrey Mattox wrote:
If I do this, theDictionary gets a retainCount of 1.:
NSMutableDictionary *theDictionary =
[NSMutableDictionary dictionaryWithCapacity:1];
1. Is it in the autoRelease pool? Is that the case with all class
methods that create and return objects?
Yes, and it is the normal behavior of all of Apple's class methods that
do that. 3rd Party classes may behave differently, but they shouldn't.
2. If I have a big loop that uses an NSString in the loop, is it
considered good form (to conserve memory) to use alloc/init and then
release the string from the previous loop, thusly:
If memory is your priority, I would take this route... but if you need
speed, that is going to be slow as snot on a loop that iterates
thousands of times. The best (IMO) for a speedy loop is to create
objects in an autoreleased state and ignore the deallocation. That way
the cycles needed to collect the memory from them is used during the
run loop, rather than your tight loop.
3. I've looked as the utility ObjectAlloc, but it generates an
unwieldy output. Is that the best way to find leaks due to objects I
explicitly create? Is there a way to reduce the clutter?
I honestly don't know this one.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.