• 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: Cache Class review (low priority)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cache Class review (low priority)


  • Subject: Re: Cache Class review (low priority)
  • From: Uli Kusterer <email@hidden>
  • Date: Fri, 2 May 2008 22:29:12 +0200


Am 02.05.2008 um 20:03 schrieb Jens Alfke:

You're probably running this as a GUI-less tool process, i.e. directly calling your code from main(). If you do this, you need to create a top-level autorelease pool before calling into your code. In general, main() looks like:
int main( int argc, const char **argv ) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int result = 0;
// your program code goes here
[pool drain];
return result;
}

Well, this only shuts up the warnings, it doesn't really keep the memory from leaking because the pool isn't drained until the app quits.


If you have any sort of loop in your app, you'll want to put the pool inside that loop, so a new pool gets created and the old pool gets released for every command you execute.

But don't put the pool inside your accessors or other such small places. Particularly as generally you want a pool outside a function when you're returning an object from it, so the pool can temporarily take ownership of the object after your function has terminated. That is, if you're not garbage-collected, in which case this doesn't apply.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

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: 
 >Re: Cache Class review (low priority) (From: Gregory Weston <email@hidden>)
 >Re: Cache Class review (low priority) (From: Jens Alfke <email@hidden>)
 >Re: Cache Class review (low priority) (From: Western Botanicals <email@hidden>)
 >Re: Cache Class review (low priority) (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Graphics seen when volume is modified.
  • Next by Date: Re: Unit Test error XCode 3.1 (Beta)
  • Previous by thread: Re: Cache Class review (low priority)
  • Next by thread: Re: Cache Class review (low priority)
  • Index(es):
    • Date
    • Thread