(image from: apple developer site)

In my company, I'm making iOS applications.

And yesterday, I found a very strange memory leak.

I can't show you the real source code in my project.

Therefore I made new test project.

following interface is the hot potato.

and this is the test code.

When I analyze this project.
There is no problem.

But !!

The profiler shows me something other OTL .

Can you understand it??
I spent several minutes agonizing over this problem.
And finally I found the problem.

The problem is "Binding between ivar and property".

When ivar "_a" and property "a" are declared even they are not binded,
compiler and analyzer think like that these variables are already binded.

(ex : @synthesize a = _a;)
That is the reason  why there is no warning message from compiler and analyzer.

But at real compile time, compiler can not make any bindings between those, because there is no actual binding. 

Therefore _tmpArray can not be accessed by other interfaces. And there is no code to release property.

To solve this problem, we have to bind these explicitly.

if you want to hide ivar using this example.

and if you don't need to hide it, do like this.




박상건 - gunnih