Hi there all, I am relatively new, and from what I can tell, I am doing the following correctly using GC (required) on my XCode Project.
The following is a test application that demonstrates what I am seeing. If you look at the application in Activity monitor, you will see the threads go up every second. Is there something that I am missing? For a long-running application that has the following in a thread loop, this causes a huge issue, as I can't seem to get these threads to clean up. I have also tried dealloc(), setting the pointers to nil and NULL, and calling -terminate: on the NSTask before I exit the runCommand:: method; Thanks in advance for any light you can shed on this issue. #import <Cocoa/Cocoa.h> @interface mainTest :NSObject { } @end @implementation mainTest -(NSString *)runCommand:(NSString *) pathToCommand withArguments:(NSArray*)args { NSTask *task = [[NSTask alloc] init]; // initialise a NSTask for launching the process NSPipe *newPipe = [NSPipe pipe]; // initialise a one-way channel NSFileHandle *readHandle = [newPipe fileHandleForReading]; // to read the process output NSData *inData; // the process output will be passed to a NSData NSString *tempString; // and the NSData will be converted to a NSString // Set up the operating conditions for the task [task setCurrentDirectoryPath:NSHomeDirectory()]; [task setLaunchPath: pathToCommand]; [task setArguments:args]; [task setStandardOutput:newPipe]; // The Unix output is fed into the NSPipe // Now launch the process [task launch]; // Read everything sent and store in NSData inData = [readHandle readDataToEndOfFile]; // Set up a temporary NSString containing the contents of the NSData tempString = [[NSString alloc] initWithData:inData encoding: NSASCIIStringEncoding]; // Return the NSString holding the output of the Unix process return tempString; } @end int main (int argc, const char * argv[]) { mainTest* mainT = [mainTest new]; while(true) { NSLog([mainT runCommand: @"/bin/date" withArguments:[NSArray new]]); sleep(1); } return 0; } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]