views:

965

answers:

2

There are environment variables you can set to help debug memory issues on the Mac, but how do you set the environment variables or enable these flags described in NSDebug.h for iPhone development?

NAME OF ENV. VARIABLE               DEFAULT    SET TO...
NSDebugEnabled                        NO       "YES"
NSZombieEnabled                       NO       "YES"
NSDeallocateZombies                   NO       "YES"
NSHangOnUncaughtException             NO       "YES"

NSEnableAutoreleasePool              YES       "NO"
NSAutoreleaseFreedObjectCheckEnabled  NO       "YES"
NSAutoreleaseHighWaterMark             0       non-negative integer
NSAutoreleaseHighWaterResolution       0       non-negative integer

Here is a related article on how to do it for general Mac development I guess. Maybe it's the same way for iPhone, but since I'm new to the Mac, how are theses environment variables picked up by the simulator?

http://www.cocoabuilder.com/archive/message/cocoa/2003/7/15/90466

+3  A: 

You have to go into the "Get info" contextual menu of your executable (inside the "Executables" group in the left panel of XCode). Then go in the arguments tab. You can add the environnement variables that you specified above in the box at the bottom ("Variables to set in the env.". Simply type YES or NO, you don't need to use quotes, it's already a string token.

François P.
Nice job, thanks!
This is a really great tip!
rpetrich
+1  A: 

Plus, I can recommend calling [NSAutoreleasePool showPools] to get a log of the current pool levels and contents.