Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leak problem in Cocoa NSMutableArray/objectEnumerator



On 2004-08-27, at 12.52, Professor Leslie Smith wrote:

> I don't think this program should not fail at all.
> It looks as though the NSMutableArray objectEnumerator is not being 
> deallocated entirely.
> This is a real difficulty if one is to use NSMutableArray as one would 
> wish - in my own case, in a long simulation.
>
> I have reported this as a bug: (3778469).
> I haven't had time to try it out on a plain NSArray.
> Is this a known problem? Has anyone a workaround? (preferably short of 
> using C arrays).
> (Or have I simply misunderstood something?)

You have probably simply not understood when / how autoreleased objects 
are deallocated. I suggest that you find the documentation and refresh 
your understanding of Cocoa memory management.

The reason that the memory management is not working as automatically 
as you might be used to in a simple Cocoa application is that you're 
running in a tight loop, not allowing the regular run loop to run to 
completion. It is only at the end of the current run loop that the 
"default" autorelease pool, the one you "get for free" from the kit, is 
released, and the objects referenced by it in turn released. If you 
never allow for this to happen you'll simply collect autoreleased 
objects until you run out of memory.

Search on Google for "autorelease loop" for tips and tricks on how to 
deal with this.

j o a r

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Leak problem in Cocoa NSMutableArray/objectEnumerator (From: Professor Leslie Smith <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.