• 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: Leak problem in Cocoa NSMutableArray/objectEnumerator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leak problem in Cocoa NSMutableArray/objectEnumerator


  • Subject: Re: Leak problem in Cocoa NSMutableArray/objectEnumerator
  • From: Heath Raftery <email@hidden>
  • Date: Sat, 28 Aug 2004 01:17:33 +1000

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>)

  • Prev by Date: Re: Leak problem in Cocoa NSMutableArray/objectEnumerator
  • Next by Date: Xcode build system... what's the best choice?
  • Previous by thread: Re: Leak problem in Cocoa NSMutableArray/objectEnumerator
  • Next by thread: OT: prebind warnings not always correct...
  • Index(es):
    • Date
    • Thread