NSEnumerator retaining objects?
NSEnumerator retaining objects?
- Subject: NSEnumerator retaining objects?
- From: James Bucanek <email@hidden>
- Date: Tue, 8 Mar 2005 10:20:55 -0700
I'm trying to track down some memory leaks and I'm running into something weird. At least I think it is....
I'm running ObjectAlloc and watching the retain/release/autorelease cycles of a few objects. I expected to see two or three events per object, but I'm seeing thousands. When I step through the ObjectAlloc events, it refers to code that looks like this:
1: NSEnumerator* e = [array objectEnumerator];
2: Node* node;
3: while ( (node=(Node*)[e nextObject])!=nil )
4: {
5: // do something with node
6: }
Every node object is seeing a retain followed by an autorelease on line 3. Does NSEnumerator retain every object it iterates through, then autorelease it on the next pass through the loop?
I have several concerns with this, so if this is what objectEnumerator does then I might have to roll my own enumerator or just go back to good 'ol for(;;) loops.
James
--
James Bucanek <mailto:email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden