• 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: Enabling NSZombieEnabled programatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enabling NSZombieEnabled programatically


  • Subject: Re: Enabling NSZombieEnabled programatically
  • From: Ben Haller <email@hidden>
  • Date: Sun, 10 Jan 2010 11:10:57 -0500

On 10-Jan-10, at 8:41 AM, Dave Keck wrote:

After checking the CF sources for 10.5
(http://opensource.apple.com/source/CF/CF-476.19/CFRuntime.c), it
would appear that the check for the NSZombieEnabled environment
variable comes in a GCC constructor. Therefore setting the
NSZombieEnabled environment variable from within your app's image
would be impossible (since the constructors for frameworks you link to
are executed before your own). I suppose you could create a framework
or dynamic library (that doesn't link CF directly or indirectly)
expressly for the purpose of setting the NSZombieEnabled environment
variable, but that's a little crazy.

Furthermore, CF couldn't be checking the NSZombieEnabled global
variable since it's defined in the higher-level Foundation framework.
For this reason, zombies could never be enabled for CF objects by
setting the NSZombieEnabled global in NSDebug.h. Which probably isn't
what you want.

These two facts combined means to my knowledge, there's no better way
to enable zombies than to relaunching your app.

(It would appear that 10.6 introduced _CFEnableZombies(), though...)

Some old code I have lying around does this:

int main(int argc, const char *argv[]) {
    // Catch any autorelease activity
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSArray *arguments = [[NSProcessInfo processInfo] arguments];
    NSDebugEnabled = [arguments containsObject:@"-debug"];
    NSZombieEnabled = [arguments containsObject:@"-zombies"];
    [pool release];
    return NSApplicationMain(argc, argv);
}

instead of the standard main() code:

int main(int argc, const char *argv[])
{
    return NSApplicationMain(argc, argv);
}

This used to work (circa 10.4 era); it sounds from Dave's post above like it might not work on 10.6 though. Haven't tried it myself any time recently.

Ben Haller
Stick Software


_______________________________________________

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


References: 
 >Enabling NSZombieEnabled programatically (From: Graham Cox <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: "Sean McBride" <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: Jim Correia <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: Graham Cox <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: Quincey Morris <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: "Paul Sanders" <email@hidden>)
 >Re: Enabling NSZombieEnabled programatically (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: if statement causing 32 Byte leak?
  • Next by Date: [MEET] CocoaHeads-NYC this Thursday, 11/12
  • Previous by thread: Re: Enabling NSZombieEnabled programatically
  • Next by thread: [iPhone] NSCoder Question
  • Index(es):
    • Date
    • Thread