• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSThread and NSAutoReleasePool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >NSThread and NSAutoReleasePool (From: Anthony Duer <email@hidden>)

  • Prev by Date: Re: Classes and the Production of Objects
  • Next by Date: Re: Where to pu setIndicatorImage: ?
  • Previous by thread: NSThread and NSAutoReleasePool
  • Next by thread: Re: Where to pu setIndicatorImage: ?
  • Index(es):
    • Date
    • Thread