• 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: C++ instance variables not destructed if NSZombieEnabled
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ instance variables not destructed if NSZombieEnabled


  • Subject: Re: C++ instance variables not destructed if NSZombieEnabled
  • From: Greg Parker <email@hidden>
  • Date: Mon, 22 Dec 2008 13:54:19 -0800

On Dec 22, 2008, at 6:49 AM, Klaus Backert wrote:
In an application of mine I have some Objective-C classes with C++ instance variables (the Objective-C things own the C++ things). I build with the option GCC_OBJC_CALL_CXX_CDTORS = YES, i.e. run non- trivial default constructors and destructors on C++ instance variables of Objective-C classes.

As long as I do *not* set the environment variable NSZombieEnabled to YES, everything works like this: Constructors of C++ instance variables have been called when returning from NSObject's init, and destructors have been called when returning from NSObject's dealloc.

But if I do set NSZombieEnabled to YES, then the destructors are *not* called anymore (by the way, setting NSDeallocateZombies to YES or NO does not make a difference).

I can observe all this with logging and debugging.

Does anybody know, if this is normal behavior, or what else? It looks like there is an annoying difference: With zombies enabled, dealloc methods of Objective-C are invoked, but destructors of C++ are not called.

It's a loophole in the implementation of NSZombie. Sorry. You might be able to use Guard Malloc instead (man libgmalloc); it doesn't have that destructor problem.



-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

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


  • Follow-Ups:
    • Re: C++ instance variables not destructed if NSZombieEnabled
      • From: Klaus Backert <email@hidden>
References: 
 >C++ instance variables not destructed if NSZombieEnabled (From: Klaus Backert <email@hidden>)

  • Prev by Date: Re: NSCalendar/NSDate - generating all months/days in a year
  • Next by Date: Re: NSMutableArray sorting
  • Previous by thread: C++ instance variables not destructed if NSZombieEnabled
  • Next by thread: Re: C++ instance variables not destructed if NSZombieEnabled
  • Index(es):
    • Date
    • Thread