• 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: In-loop releasing of objects does not free memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In-loop releasing of objects does not free memory?


  • Subject: Re: In-loop releasing of objects does not free memory?
  • From: Randall Meadows <email@hidden>
  • Date: Thu, 14 Feb 2008 09:31:02 -0700

On Feb 14, 2008, at 1:43 AM, Arthur C. wrote:

I think a better way to explain this would be, "try wrapping the body of > the loop in an autorelease pool."
That did the job. It is simple:
{ // loop
  NSAutoreleasePool * loopPool = [[NSAutoreleasePool alloc] init];
  <do various things>
  [loopPool release];
}

Indeed, there were autoreleased objects created in the loop that I didn't consider.

In theory, a better way to do this would be:

NSAutoreleasePool * loopPool = [[NSAutoreleasePool alloc] init];
{  // loop
  <do various things>
  [loopPool drain];
}

But I have to admit, I recall having an issue where drain: didn't seem to work very well, so I ended up doing exactly what you did. It didn't seem to be a performance issue for me, so I didn't take the time to investigate why drain: didn't work; it bugged the crap out of me to be creating an object like that every time through the loop, but I had more pressing things to deal with.

Anyone else noticed this behavior with drain: or otherwise have an explanation?
_______________________________________________


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: In-loop releasing of objects does not free memory?
      • From: Uli Kusterer <email@hidden>
References: 
 >In-loop releasing of objects does not free memory? (From: Arthur C. <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: John Terranova <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: John Stiles <email@hidden>)
 >RE: In-loop releasing of objects does not free memory? (From: Arthur C. <email@hidden>)

  • Prev by Date: Re: logging object creations and destructions
  • Next by Date: Re: animating a non-interpolated view property and totally confused
  • Previous by thread: RE: In-loop releasing of objects does not free memory?
  • Next by thread: Re: In-loop releasing of objects does not free memory?
  • Index(es):
    • Date
    • Thread