• 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: ss2 cire <email@hidden>
  • Date: Sat, 9 Feb 2008 23:13:45 -0800

Oh, that's true....

so change [array addObject:bar] to...

[array addObject:[bar autorelease]];

and that really should do it, but like others have said, there's probably something else going on
with the code... is there anything more you can send us? maybe use a paste site to hold the code?


regards,

Eric

On Feb 9, 2008, at 11:02 PM, Bill Bumgarner wrote:

On Feb 9, 2008, at 10:57 PM, ss2 cire wrote:
yay, one i THINK i can answer =)

I thought NSArray already automatically retained all objects that were added to it?
then once the array is released (dealloced?) the objects within are released as well
so you may only need to just send it an auto released object


so...

void foo()
{
	[array removeAllObjects];
	Bar *bar = [[Bar alloc] init];

	[array addObject:bar];
}


that should work fine, shouldn't it?

please correct me if I'm wrong.

Double retain.

[array removeAllObjects]; // leaks the doubly-retained bar

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


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>)
 >Re: Memory management with arrays (From: ss2 cire <email@hidden>)
 >Re: Memory management with arrays (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: CoreData: Save password securly
  • Next by Date: Re: NSTableView Data Binding Problem
  • Previous by thread: Re: Memory management with arrays
  • Next by thread: Re: Memory management with arrays
  • Index(es):
    • Date
    • Thread