• 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: NSTask memory leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask memory leak


  • Subject: Re: NSTask memory leak
  • From: Stefan Werner <email@hidden>
  • Date: Wed, 29 Nov 2006 19:19:28 +0100


On Nov 29, 2006, at 6:19 PM, Shawn Erickson wrote:

What you should do is ensure an autorelease pool is in place during
any method call that sends objective-c messages and released on exit
from such methods (note the that in a Cocoa application an autorelease
pool is managed for you on the main thread).

Well, I did try different patterns of creating/destroying the autoreleasepools with no success so far, including creating/ destroying one per thread. Making it a member of the C++ class seemed like the most convenient way, but I see now that this only works as long as only one instance of that class exists at a time (which actually is true in my case).


Any NSObject subclass
that you need to exist for the life of your C++ class must have either
an implicit retain (alloc, copy, etc.) or explicit retain on the
object. Then on destruction of the C++ is must balance that retain
with a release (or autorelease).

Given that my NSTask is created through alloc/init an later released explicitly and all the other Cocoa objects in my C++ class are autoreleased implicitly, I should be fine here, right?


Stefan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: NSTask memory leak
      • From: glenn andreas <email@hidden>
    • Re: Re: NSTask memory leak
      • From: "Shawn Erickson" <email@hidden>
References: 
 >NSTask memory leak (From: Stefan Werner <email@hidden>)
 >Re: NSTask memory leak (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: nsview anti-aliasing again
  • Next by Date: Re: nsview anti-aliasing again
  • Previous by thread: Re: NSTask memory leak
  • Next by thread: Re: Re: NSTask memory leak
  • Index(es):
    • Date
    • Thread