Re: Memory Leak while using NSTask repeatedly
Re: Memory Leak while using NSTask repeatedly
- Subject: Re: Memory Leak while using NSTask repeatedly
- From: Chris Ridd <email@hidden>
- Date: Thu, 16 Oct 2003 19:25:37 +0100
On 16/10/03 5:42 pm, Huyler, Christopher M <email@hidden>
wrote:
>
Is there some more clean-up that I am missing?
The autorelease pool is filling up with more and more copies of your
arguments, and you are not clearing the pool.
So there probably isn't a leak.
If you create a new pool at the start of the loop and release it at the end
(by the sleep()) your memory usage should stablize.
BTW: polling for your process is "tacky", in that it uses unnecessary CPU.
If there's another way to do it...
Also if you're just trying to test for the existence of a process which you
know the pid for, try calling kill(pid, 0). That will succeed if the process
is there, and fail if it isn't. That will be *much* cheaper than calling ps
repeatedly :-)
Read 'man 2 kill' for the details.
Cheers,
Chris
_______________________________________________
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.