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



Leslie,

You've most likely addressed this, but the first thing which struck me as I read your email was the method of "creation" of your array. I thought it might be best to mention it, just in case!

On 27/08/2004, at 8:52 PM, Professor Leslie Smith wrote:
NSMutableArray *MyArray  is declared in the header.
It is created using
[NSMutableArray arrayWithCapacity: 100] ;
and then filled with NSNumber objects.

How and when exactly is this done? Do you realise that the array... factory methods return an autoreleased object? That is, if you created MyArray with MyArray = [NSMutableArray arrayWithCapacity:100]; then it is up for garbage collection as soon as the current autorelease pool is released, which is likely to be as soon as this current scope ends. Is there any chance you actually meant the following?


//create MyArray (which is declared in the header, as a member of my class)
MyArray = [[NSMutableArray alloc] initWithCapacity:100];


Heath
_______________________________________________
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.