How do I set up NSZombieEnabled in Xcode 4?

前端 未结 7 1063
栀梦
栀梦 2020-11-21 13:03

How do I set up NSZombieEnabled and CFZombieLevel for my executable in Xcode 4?

相关标签:
7条回答
  • 2020-11-21 14:02

    I find this alternative more convenient:

    1. Click the "Run Button Dropdown"
    2. From the list choose Profile
    3. The program "Instruments" should open where you can also choose Zombies
    4. Now you can interact with your app and try to cause the error
    5. As soon as the error happens you should get a hint on when your object was released and therefore deallocated.

    Zombies

    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:

    1. If you forget to uncheck the option in the diagnostic tab there no objects will be released from memory.

    2. You get a more detailed stack that shows you in what methods your corrupt object was allocated / released or retained.

    0 讨论(0)
提交回复
热议问题