On 22.12.2008, at 22:54, Greg Parker wrote:

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).

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.

Thank you for this very useful information.

When debugging with Guard Malloc – and without zombies enabled –, the C ++ destructors are called again indeed. I'm glad.

But, because the slowdown is remarkable – which I expected, because man libgmalloc tells about it –, I will not use this all the time during debugging, as I did with zombies enabled previously.

Kind regards
Klaus

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to