• 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: App crashes on thread exit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: App crashes on thread exit


  • Subject: Re: App crashes on thread exit
  • From: Cameron Hayne <email@hidden>
  • Date: Sat, 12 Oct 2002 16:27:52 -0400

On 12/10/02 1:33 pm, "Fabio Genoese" <email@hidden> wrote:

> - (void)sThread:(id)address
> {
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> NSLock *theLock = [[NSLock alloc] init];
> Server *s = [[Server alloc] init];
> NSMutableDictionary *record = [[NSMutableDictionary alloc] init];
>
> if ([theLock tryLock]) {
> s = [qstat queryServer:address];
> record = [s data];
> [records addObject:record];
> }
> [theLock unlock];
> [pool release];
> }

Several comments:
1) It seems that qstat & records are ivars. Have you retained them?
2) I don't see the point of having the NSLock here. Usually you create an
NSLock object somewhere before your program becomes multi-threaded - i.e. at
initialization, and then use it in more than one thread.
3) Usually you do the pool alloc & release at the beginning and end of each
thread - not in some short-lived method which gets invoked several times in
the thread. Nothing wrong with doing this as far as I can see, but not
necessary to do it so often.
4) You are overwriting the value of the 'record' pointer you allocated with
the value you get back from [s data].

--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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.

  • Follow-Ups:
    • Re: App crashes on thread exit
      • From: Fabio Genoese <email@hidden>
References: 
 >Re: App crashes on thread exit (From: Fabio Genoese <email@hidden>)

  • Prev by Date: Re: Two ways to get this NSTableView behaviour but I do not know how to implement either
  • Next by Date: Re: Two ways to get this NSTableView behaviour but I do not know how to implement either
  • Previous by thread: Re: App crashes on thread exit
  • Next by thread: Re: App crashes on thread exit
  • Index(es):
    • Date
    • Thread