Re : Application is crashing if it runs for long time (On NSTask)
Re : Application is crashing if it runs for long time (On NSTask)
- Subject: Re : Application is crashing if it runs for long time (On NSTask)
- From: Raghunatha Reddy <email@hidden>
- Date: Tue, 15 Oct 2002 19:26:13 -0700
I am able to solve the problem in an improper way, but found some
interesting behaviors.
If I call the method "startShellScript" in a loop for 247 times the method
fails. Releasing object "handle" (even though we are not allocating and
retaining) and calling method to execute script in a loop will works fine. I
think the autorelease pool crossed it's limits for the current event
process.
In my application I am using a thread to run the script in a loop. With
releasing *handle* in startShellScript method, the application works fine
until thread is running (checking script return value). On successful return
from script thread exits and application crashes.
If I remove autorelease pool in the thread the application works fine with
exceptions in the console. Suggestions please ;-)
Reddy
>
> [script release];
>
>
Message: 13
>
Date: Fri, 11 Oct 2002 19:48:21 -0500
>
Subject: Re: Application is crashing if it runs for long time (On
>
NSTask)
>
Cc: <email@hidden>
>
To: Raghunatha Reddy <email@hidden>
>
From: Charles Srstka <email@hidden>
>
>
Run it in the debugger, and when it crashes, click on startShellScript
>
in the list of methods that are running. It should highlight the exact
>
line where it's crashing. That should help narrow it down.
>
>
Charles
>
>
On Friday, October 11, 2002, at 04:25 PM, Raghunatha Reddy wrote:
>
>
> Hi,
>
>
>
> I have a application which runs a shell script. The script will be
>
> running
>
> in a loop to capture some events.
>
>
>
> The application runs fine for short time, and crashes if it runs for
>
> long
>
> time. Any ideas?
>
>
>
> I am calling the method "startShellScript" in a loop from other
>
> object. Do I
>
> need to release the "handle" here?. I am getting the following error.
>
>
>
> [NSCFDictionary setObject:forKey:]; attempt to insert nil value.
>
> Exited due
>
> to signal 5.
>
>
>
>
>
> - (NSString *) startShellScript:(NSArray *) args{
>
>
>
> NSPipe *pipe=[[NSPipe alloc] init];
>
> NSFileHandle *handle;
>
> NSString *scriptReturn;
>
>
>
>
>
> // initialize the task
>
> NSLog(@"initialize the task");
>
>
>
> //NSTask* script; declared in header
>
> script = [[NSTask alloc] init];
>
>
>
> [script setLaunchPath:path];
>
>
>
> if (args != nil)
>
> [script setArguments:args];
>
>
>
> // I AM GUESSING IT IS FAILING HERE
>
> [script setStandardOutput:pipe];
>
> handle = [pipe fileHandleForReading];
>
>
>
>
>
> [script launch];
>
> [script waitUntilExit];
>
>
>
> scriptReturn = [[NSString alloc] initWithData:[handle
>
> readDataToEndOfFile] encoding:NSASCIIStringEncoding];
>
>
>
> [pipe release];
>
> [script release];
>
>
>
> // This object is getting released in the caller method
>
> return scriptReturn;
>
> }
>
> _______________________________________________
_______________________________________________
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.