My Code is like below, under ARC in IOS7.1.
void function
{
for (int i = 0; i < 100000; i++)
{
UIImage *buttonBar_test = [[UIImage alloc] init];
//[buttonBar_test release];
}
}
Although the ref count drops to 0, the temp objects(buttonBar_test) still alive, not freed by the system after the function returns. Why?
![in the instrument->allocations, enable to "Record reference counts"][1]
![after the function returns, the temp objects still got alive, very strange?!][2]
![the reference count drops to 0, but no "free" was called on the objects, so the objects are still alive][3]
I created a demo project, this issue doesn't exist. But in my own project, it exist. I don't know why, are there any configuration related to this issue?
(Also, my own project links some 3rd party dependencies which didn't enable arc, but in my global linker flag settings, it contains: -fobjc-arc)
If dealloc
was called, but the memory backing the object was not released, there are two possibilities:
[super dealloc]
at the end of your -dealloc
(only applies to non-ARC code)Most possible that you have Zombies enabled
,
Here is a small guide how to disable it.
1) Open scheme editor.
2) Click on Run $<Project name>
(tag 1)
3) Click on Diagnostics
(tag 2)
4) Uncheck Enable Zombie Objects
.