• 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: Running an NSTask Within an NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running an NSTask Within an NSThread


  • Subject: Re: Running an NSTask Within an NSThread
  • From: Shripada Hebbar <email@hidden>
  • Date: Mon, 28 Jan 2008 10:02:39 +0530

Hi Jon,


I'm writing an app that needs to run a fairly lengthy background
process, but the process itself is an NSTask.  Does the task itself
run on its own thread anyway or am I better spawning a new thread from
my main one?  What would be any possible disadvantage? The docs say
that a task runs in a separate memory space to the calling app, but I
don't know if that's the same thing.

Task that you intend to run is actually a separate process and NSTask class provides
the necessary setup to run that process and get the results. It hooks to the run loop of the
thread in which it was executed.



When I don't span a new thread I get NSLogs showing that two calls to my -taskDidFinish:(NSNotification *)note method and a crash.
I do not have an idea why it fires -taskDidFinish notification twice. And the reason why
it crashes is evident from your code that you end up releasing the task object twice as
the notification is called twice. To be on safer side, soon after releasing the object, initialize
it to nil.



When I spawn a thread, I get no calls to the -taskDidFinsh method, therefore I have a memory leak! Any ideas?

I suspect that you do not have a run loop running in your secondary thread. Thats the exact reason
why you are not getting the notification and thus your object is not being released.




Regards
Shripada

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: designing beyond MV and (one) C
  • Next by Date: Re: The mouse is where, again?
  • Previous by thread: Re: Running an NSTask Within an NSThread
  • Next by thread: Trying to bind to reverseTransformedValue: in IB
  • Index(es):
    • Date
    • Thread