I am getting a memory leak in my objective-C code that I don’t understand. I have this code in a method that gets called several times:
AnalyzeBpm *analyzer = [[AnalyzeBpm alloc] init];
while( sample != NULL)
{
//do something with analyzer
}
[analyzer release];
When I run this code through Instruments, I get a leak everytime I allocate Analyze Bpm(which is a couple of hundred times). I looked at my AnalyzeBpm class, and everything I allocate in that class gets freed or deallocated. So why is this code creating a memory leak?
When Instruments identifies a leak, it is showing you the line of code that is allocating the leak, not the line of code that causes the leak.
Somewhere something is retaining
analyzerwithout releasing it. You need to find that unbalancedretain. It may or may not be in theAnalyzeBpmclass.