Skip navigation.
 
mlRe: running out of NSPipes
FROM : justin webster
DATE : Sat Apr 19 04:21:40 2008

I guess it may be a bug.
I achieved more or less the same thing bypassing NSTask and NSPipe 
and now have no issues with resource management.
the trick, I think, was fflush() and pclose(). perhaps NSPipe is 
missing some tidy-up code.
there probably are more efficient ways of doing this but efficiency 
is not really a concern in my case.

for the record - here's an example which works:
   int f;
   for(f=0; f<5000; f++){
       fflush(nil);
       FILE *rtn = popen([@"ls" cString], [@"r" cString]);
       //here we use the output of the pipe
       pclose(rtn);
   }

thanks for the help
justin

On 19/04/2008, at 12:15 PM, Ken Thomases wrote:

> On Apr 18, 2008, at 6:05 PM, justin webster wrote:

>> I'm pretty sure I've got everything alloc'ing and releasing in the 
>> right way

>
> I agree.  It all looks correct.  It may very well be a bug in the 
> framework.
>
> One last thing to check: does some part of your code register for 
> the NSTaskDidTerminateNotification notification, presumably without 
> specifying a task object, but listening for all of them?  If so, 
> might it be retaining the notification object which is the task 
> object?
>
> If there's no other explanation, I recommend that you file a bug at 
> bugreport.apple.com.
>
>
> That said, to accomplish what you need I recommend that you use 
> sysctl(3) to get the information from the system directly without 
> launching the ps process.  Here's some code from Apple that you can 
> adapt: http://developer.apple.com/qa/qa2001/qa1123.html
>
> Good luck,
> Ken
>

Related mailsAuthorDate
mlrunning out of NSPipes justin webster Apr 18, 11:23
mlRe: running out of NSPipes Scott Ribe Apr 18, 14:21
mlRe: running out of NSPipes Ken Thomases Apr 18, 21:15
mlRe: running out of NSPipes justin webster Apr 19, 04:21
mlRe: running out of NSPipes Jens Alfke Apr 19, 06:39
mlRe: running out of NSPipes justin webster Apr 19, 06:58
mlRe: running out of NSPipes Bob Smith Apr 19, 09:45
mlRe: running out of NSPipes Jens Alfke Apr 19, 17:20