NSThread and NSAutoReleasePool
NSThread and NSAutoReleasePool
- Subject: NSThread and NSAutoReleasePool
- From: Anthony Duer <email@hidden>
- Date: Sat, 10 Aug 2002 10:24:56 -0700
Hi, I'm having a bit of trouble with a multi-threaded program I'm
writing in which at the end of the Thread's run, the NSAutoReleasePool
seems to cause a double free when it is released. After much fiddling,
I've narrowed down exactly which line is doing it. The thread is
launched on the goSocket: function. Relevant code below...
-(void)goSocket:(NSString *key)
//Create and connect the socket here...
//After creating, I'll read in my Data...
[mySocket readData: myData];
while([myData containsString:@"\n"])
{
NSString *line = [[NSString alloc] initWith
Data:[myData
dataUpToString:@"\n"] encoding: NSUTF8StringEncoding];
NSRange ofLOA = [line rangeOfCharacters: @"LOA"];
if(LOA.length == 0)
{
[mainTextView insertText: line];
}
else
{
[self sendOut: line]; //Right here this causes a problem.
}
}
in sendOut, a string is alloc'd and init'd with line's string. Thus I
think the leak is coming from sending line out as an argument from the
thread. I'm getting the feeling I'm violating some aspect of thread
safety, but it eludes me as to what. Any help is appreciated. :)
~Anthony
_______________________________________________
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.