A bit attention about NSZombieEnabled
As a developer, we often need to resolve the memory problems in our apps. One of those is about over release. This situation occurs when sending a release message to the object which "retain count" has already been 0. But as default, the debug message of that error is hard to find the reason of the problem. So, iOS provide an environment variable which name is "NSZombieEnabled". When you set it to YES, you will see the detail information about any over release errors.
Although, most of us has already known this variable and use it frequently. However, we also need to understand the principle behind it. In short, when a object been released, the memory it taken will be cleaned. So, the system can not figure out any information about that object when we send a message after it been released. This is the reason that we can not get any detail error information after the memory been cleaned.
For that reason, iOS provide an mechanism that do not actually clean the memory after the release method been called. That is the real work NSZombleEnabled do. At that condition, the object's memory will not been cleaned even if it "retain count" decreased to 0. The memory have been reserved. So, when an error like "over release" occurs, the system can figure out the detail information about this error.
Because NSZombieEnabled will reserve any memory we taken. So, we must disable it when we finally complete our development progress. If not, our apps will take much memory and not actually release any memory it taken.
|