Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

MemoryLeak in iphone programming?

Can any one help me to understand the problem in this image

enter image description here

Upvotes: 0

Views: 123

Answers (3)

Narayana Rao Routhu
Narayana Rao Routhu

Reputation: 6323

You have initialize the locs array then you have to release that array before closing that function: [locs release];locs=nil;

Upvotes: 0

EmptyStack
EmptyStack

Reputation: 51374

As the analyzer says, you are allocating locs on line 647, using
NSMutableArray *locs = [[NSMutableArray alloc] init]; and not releasing it later in the block. You should release it or you can use convenience constructor to get the autoreleased array like this, NSMutableArray *locs = [NSMutableArray array];

I'd suggest you to still simplify your code to this,

NSMutableArray *annotations = (NSMutableArray *)[map annotations];
[annotations removeObject:[map userLocation]];
[map removeAnnotations:annotations];

Upvotes: 4

jrtc27
jrtc27

Reputation: 8536

You need to release locs at the very end. You have alloc'ed and init'ed it, giving it a reference count of 1, an then you should release it to change the reference count to 0. Refer to http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/ for more info.

Upvotes: 1

Related Questions