Re: NSThread and NSAutoReleasePool
Re: NSThread and NSAutoReleasePool
- Subject: Re: NSThread and NSAutoReleasePool
- From: Olivier <email@hidden>
- Date: Sat, 10 Aug 2002 14:54:14 -0500
in your mail you first mention a double free then a leak. Which one is
the problem?
Where do you autorelease the string line? the code you sent never
releases it even though it created it.
I don't know much about thread so if it is really a threading problem i
won't be of much help.
Olivier
On Saturday, August 10, 2002, at 12:24 PM, Anthony Duer wrote:
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] initWithData:[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.
_______________________________________________
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.