• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSEnumerator retaining objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSEnumerator retaining objects?
      • From: "John C. Randolph" <email@hidden>
    • Re: NSEnumerator retaining objects?
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: New game on ADC Web site?
  • Next by Date: Re: NSEnumerator retaining objects?
  • Previous by thread: NSTableView
  • Next by thread: Re: NSEnumerator retaining objects?
  • Index(es):
    • Date
    • Thread