How do I set up NSZombieEnabled in Xcode 4?
How do I set up
CFZombieLevel for my executable in Xcode 4?
- What is NSZombie?
- XCode Instrument - Allocations Instrument not finding zombies
- Enable and Debug Zombie objects in iOS using Xcode 5.1.1
- How to set environment variables in iPhone executable using XCode 4?
- iOS libsystem_c.dylib strdup memory leak NSZombie not working
- How to turn off NSZombieEnabled in Xcode 4
7 Solutions Collect From Internet About “How do I set up NSZombieEnabled in Xcode 4?”
In Xcode 4.x press
select the “Diagnostics” tab and click “Enable Zombie Objects”:
This turns released objects into NSZombie instances that print console warnings when used again. This is a debugging aid that increases memory use (no object is really released) but improves error reporting.
A typical case is when you over-release an object and you don’t know which one:
- With zombies:
-[UITableView release]: message sent to deallocated instance
- Without zombies:
This Xcode setting is ignored when you archive the application for App Store submission. You don’t need to touch anything before releasing your application.
Pressing ⌥⌘R is the same as selecting Product > Run while keeping the Alt key pressed.
Clicking the “Enable Zombie Objects” checkbox is the same as manually adding “NSZombieEnabled = YES” in the section “Environment Variables” of the tab Arguments.
Jano’s answer is the easiest way to find it.. another way would be if you click on the scheme drop down bar -> edit scheme -> arguments tab and then add NSZombieEnabled in the Environment Variables column and YES in the value column…
I find this alternative more convenient:
- Click the “Run Button Dropdown”
- From the list choose
- The program “Instruments” should open where you can also choose
- Now you can interact with your app and try to cause the error
- As soon as the error happens you should get a hint on when your object was released and therefore deallocated.
As soon as a zombie is detected you then get a neat “Zombie Stack” that shows you when the object in question was allocated and where it was retained or released:
Event Type RefCt Responsible Caller Malloc 1 -[MyViewController loadData:] Retain 2 -[MyDataManager initWithBaseURL:] Release 1 -[MyDataManager initWithBaseURL:] Release 0 -[MyViewController loadData:] Zombie -1 -[MyService prepareURLReuqest]
Advantages compared to using the diagnostic tab of the Xcode Schemes:
If you forget to uncheck the option in the diagnostic tab there no objects will be released from memory.
You get a more detailed stack that shows you in what methods your corrupt object was allocated / released or retained.
In Xcode 4.2
- Project Name/Edit Scheme/Diagnostics/
- Enable Zombie Objects check box
- You’re done
On In Xcode 7
Edit Scheme from
Enable Zombie Objects form the
As alternative, if you prefer
.xcconfig files you can read this article https://therealbnut.wordpress.com/2012/01/01/setting-xcode-4-0-environment-variables-from-a-script/
Cocoa offers a cool feature which greatly enhances your capabilities to debug such situations. It is an environment variable which is called NSZombieEnabled, watch this video that explains setting up NSZombieEnabled in objective-C
In Xcode > 4.3:
You click on the scheme drop down bar -> edit scheme -> arguments tab and then add NSZombieEnabled in the Environment Variables column and YES in the value column.
Good Luck !!!
- How to insert 40000 records fast into an sqlite database in an iPad
- What exactly to digest and sign on XMLDSIG and how? (or, OSX-native client mismatches XMLDSIG calculated on server)
- How to make custom MKPolyline in SWIFT with additional argument – color
- Badge Count is not increasing for push notification.always badge count remains 1?
- UIColor colorWithRed:green:blue: always produces black
- UIStoryboard load from app delegate
- Swift 3.1: Crash when custom error is converted to NSError to access its domain property
- Getting and Setting Cursor Position of UITextField and UITextView in Swift
- Fast switching between videos using AVFoundation
- How to completely remove Realm database from iOS?
- Xcode: Referencing C++ project from Objective-C project
- Truncate NSDate (Zero-out time)
- How to use a Google offline access token to authenticate in background on iOS?
- Cordova Error 65 when trying to build app for iOS
- Transparent UITableViewCell flashing background when animating