Re: Memory Leak in Daemon
Re: Memory Leak in Daemon
- Subject: Re: Memory Leak in Daemon
- From: j o a r <email@hidden>
- Date: Mon, 19 Jul 2004 22:45:23 +0200
You are probably creating a lot of autoreleased objects that are
collected in your only autorelease pool. Create a local pool inside
your while loop, and release it every time you pass through the loop.
Something like this:
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
while ()
{
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
// Stuff
[localPool release];
sleep();
}
[pool release];
}
Don't forget to read all the documentation available on this topic,
both from Apple and third party sources!
j o a r
On 2004-07-19, at 22.36, Kodex wrote:
>
I have been putting the finishing touches on my daemon
>
and have noticed that i get a 1 MB memory leak each
>
cycle through the loop that is added onto private
>
memory. I am not sure how to release my pool or call
>
dealloc in a deamon so i think that might be the
>
cause. I have provided a link to my source code as
>
well http://dragon-forged.com/memoryleak.txt just
>
incase those arent the issues. Thanks guys!
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.