NSTask leaking ?
NSTask leaking ?
- Subject: NSTask leaking ?
- From: Yann Bizeul <email@hidden>
- Date: Fri, 3 Jan 2003 16:47:58 +0100
Hi list.
I'm currently writing an app issuing shell script at intervals. The
number of shell scripts the user can execute is not finite, so I handle
those entries is a Dictionary.
Now, when the application starts, I register for the
NSTaskDidTerminateNotification and
NSFileHandleReadCompletionNotification notifications and launch each
script with a NSTask, and store the NSTask object in a Dictionary.
My NSTask is instantiated as below :
NSTask *task = [[ NSTask alloc ] init ];
[ task setLaunchPath: @"/bin/sh" ];
[ task setArguments: arguments ];
NSPipe *pipe = [ NSPipe pipe ];
[ log setObject: task forKey:@"task" ];
[[ pipe fileHandleForReading ] waitForDataInBackgroundAndNotify ];
[ task setStandardOutput: pipe ];
[ task launch ];
[ task release ];
So I release task because I assume it is retained by the dictionary,
and I do not release pipe because it is instantiated with a convenience
contructor.
Now If I launch my app under ObjectAlloc, I say almost all variables
used in the notifications target (NSTaskDidTerminateNotification and
NSFileHandleReadCompletionNotification) not release, even enumerator
NSEnumerator *e = [ g_logs objectEnumerator ];
Seem to not be release, as the "current" count always grows. If I add a
release for them, the application stops leaking under objectalloc, but
when running alone, It crashes, as attended.
So, Is there something to do with an autorelease pool or something else
when playing with NSTask ?
One last thing, each task writes its output to a NSTextView, but I
don't think there is a problem.
I red many things saying "If tou [ xxx alloc ] something, you are
responsible of releasing them". I followed this rule perfectly, reading
many many many times the entire code to find something not released,
without success.
I found a message in the archive that seem to report something like
this, talking about a leak in NSFileHandle when no data are available,
that's my case when the process dies :
http://cocoa.mamasam.com/MACOSXDEV/2002/11/2/50324.php
but there was no answers to this question. I hope I'll be lucky :-)
--
Yann Bizeul
TYNSOE.ORG -
http://www.tynsoe.org/
Site technique consacri ` MacOS X
_______________________________________________
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.