• 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: Memory management with arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management with arrays


  • Subject: Re: Memory management with arrays
  • From: Scott Andrew <email@hidden>
  • Date: Sun, 10 Feb 2008 05:36:25 -0800

True.. (late night). So basically. Put a break in bar's dealloc. See were the extra dealloc is cooming from.

Scott

On Feb 9, 2008, at 10:38 PM, Bill Bumgarner wrote:

On Feb 9, 2008, at 10:16 PM, Scott Andrew wrote:
Here is my guess, just because i hit this recently. It had to do with the [bar autorelease] call. This returns an autoreleased object. That may not be valid when you cam back around to removeAllObjects. Try the following:

void foo
{
	[array removeAllObjects];

	Bar* bar = [[Bar alloc] init];
	[array addObject:bar];
	[bar release];
}

the following should also work..

void foo
{
	[array removeAllObjects];

	Bar* bar = [[[Bar alloc] init] autorelease];

	[array addObject:bar];

The OP's code, as posted, was fine. -autorelease returns the object being autoreleased and alloc returns an object that has been retained.


Most likely, OP has overreleased one of the objects in the array. Run with NSZombieEnabled to see what object is being overreleased. Better yet, turn on malloc stack logging (no compact) and use malloc_history to see allocation events at that address.

b.bum


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Memory management with arrays
      • From: Bill Bumgarner <email@hidden>
References: 
 >Memory management with arrays (From: Jacob Bandes-Storch <email@hidden>)
 >Re: Memory management with arrays (From: Scott Andrew <email@hidden>)
 >Re: Memory management with arrays (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: [JOB] Looking for Cocoa developers, in Paris, France
  • Next by Date: Drawing to NSView with OpenGL questions
  • Previous by thread: Re: Memory management with arrays
  • Next by thread: Re: Memory management with arrays
  • Index(es):
    • Date
    • Thread