Re: NSString Memory Management / NSAutoreleaseNoPool leaking warning
Re: NSString Memory Management / NSAutoreleaseNoPool leaking warning
- Subject: Re: NSString Memory Management / NSAutoreleaseNoPool leaking warning
- From: LAURENS Jérôme <email@hidden>
- Date: Fri, 25 May 2007 15:39:50 +0200
Le 25 mai 07 à 15:18, David Harper a écrit :
Hi,
I'm sure this is a problem everyone encounters and I think I'm
getting close to the solution. I've been programming in C++ for
the last few years so (I guess) I need a quick refresher on ObjC
memory management.
[...]
2007-05-25 09:02:38.408 IterationA[1842] *** _NSAutoreleaseNoPool
(): Object 0x7b00c of class NSCFString autoreleased with no pool in
place - just leaking
[...]
Your code executes while no autorelease pool exists to collect
autoreleased objects.
enclose your code in
id POOL = [[NSAutoreleasePool alloc] init];
/// your code where all autoreleased objects will be sent a "release"
message when POOL is released
[POOL release];
If you are using the appkit, an autorelease pool is automatically
created/released at each iteration of the main event run loop.
Basically, you must create your own NSAutoreleasePool
- in foundation tools,
- in appkit, when initializing stuff before the runloop enters for
the first time
- in appkit, when detaching threads
Moreover, you should create an NSAutoreleasePool if some limited part
of your code is expected to consume many local objects.
HTH
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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