开发者

how to using NSZombieEnabled on intrument Xcode 3.2.5

开发者 https://www.devze.com 2023-02-27 09:57 出处:网络
i have some problem in memory management, and then i try to fix it using intrument tool. Base on mark j video on you tube

i have some problem in memory management, and then i try to fix it using intrument tool.

Base on mark j video on you tube

about using NSZombieEnabled in intrument, i try to do like that. The problem is i never find a checkbox to set NSZombieEnabled active in my instrument. In this case i use xcode 3.2.5 and still on IOS 4.2.

This is the screenshot from the instrument that show no one check box for NSZombieEnabled activated :

how to using NSZombieEnabled on intrument Xcode 3.2.5

am i doing somet开发者_开发知识库hing wrong?? help me please

thank you


Try running your application on simulator and see if you get the option in instruments. You may refer this tutorial to see how it is done in XCode 3.2 or you may refer the accepted answer in this thread for XCode 4.


Why not installing the new xCode 4? There you can easily set the EnvironmentVariables in the Scheme under the tab Arguments for Debug.

To check if it is actually set I use this code...

if(
       getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")
       ) {
        NSLog(@"--------------------------------------->NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
    }


There is a simple way to enable NSZombie if you are dealing with XCode version 4 through implementation of the following simple step:

Please click on the scheme drop down bar named Product choose -> edit scheme -> arguments tab and then add NSZombieEnabled in the Environment Variables column and YES in the value column...Now you are done with enabling NSZombie to find bugs in program.

When you run your app,you get an error message where the app crashes setting NSZombie state to enabled,but originally before enabling NSZombie,you might find it difficult to find out what's exactly wrong,like crash at autorelease pool,gdb break currently using objective-c,BAD_ACCESS errors etc... By enabling NSZombie you can find what is exactly the problem such as improper deallocation and trying to re-access,or improper release of memory etc..The errors may be of the following kind:

-[ExampleProgramViewController alertView:didDismissWithButtonIndex:]: message sent to deallocated instance 0x7068f70
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号