• 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
Re: NSEnumerator retaining objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEnumerator retaining objects?


  • Subject: Re: NSEnumerator retaining objects?
  • From: James Bucanek <email@hidden>
  • Date: Tue, 8 Mar 2005 12:16:25 -0700

Shawn Erickson wrote on Tuesday, March 8, 2005:

>
>On Mar 8, 2005, at 9:20 AM, James Bucanek wrote:
>
>>Does NSEnumerator retain every object it iterates through,
>> then autorelease it on the next pass through the loop?
>
>Possibly.
>
>> I have several concerns with this,
>
>What concerns? I assume performance..?

Yes, this is an (indirect) performance issue.

The direct performance issue, that is the fact that nextObject does ends up being three calls (next/retain/autorelease) rather than just one, is annoying, but not a big problem.

The problem for me is that I have huge trees of these objects (tens of millions of them).  As I rattle through the tree, I'm going to end up with tens of millions of objects in an NSAutoreleasePool.  The only incremental solution would be to create and destroy a local NSAutoreleasePool at every node, but that's probably worse; The mean number of children for each node is about 5, meaning that I would exchange one NSAutoreleasePool with 10M objects for 2M autorelease pools with 5 objects.

But the real killer for me is that I have two procedures that walk multiple trees and combine them into a new tree.  This can be done efficiently only because I can release/destroy the nodes of the source trees as I'm building the new tree.  But if all of the nodes have been retained/autoreleased by NSEnumerator, then nothing is going to get released until the new tree is complete -- assuming I don't run out of memory first.

It's no big deal, I just wanted to see if someone could confirm this behavior.  I'm been thinking about replacing the NSMutableArrays in my tree with a simple linked-list, and this might just be reason to justify it.

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: Matt Gough <email@hidden>
References: 
 >Re: NSEnumerator retaining objects? (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: WebKit not there
  • Next by Date: Re: help viewer displays blank page
  • Previous by thread: Re: NSEnumerator retaining objects?
  • Next by thread: Re: NSEnumerator retaining objects?
  • Index(es):
    • Date
    • Thread