I have several memory leaks when testing my IOS application in xcode instruments. Can anyone see why the lines marked with “–>” are leaking?
--> CLLocationCoordinate2D newCoord = CLLocationCoordinate2DMake(latitude, longitude);
--> MapAnnotation* annotation = [[MapAnnotation alloc] initWithCoordinate:newCoord];
[mapView addAnnotation:annotation];
[annotation release];
also, I seem to have some structs which are leaking too;
--> double placeLat = [place.latitude doubleValue];
there is no pointer to the “placeLat” variable, so I can’t release it? : /
thanks
Christy
Your code is correct, as much as you show of it.
One thing you have to keep in mind is that Leaks will show you the place where the leaked object is created, not the place where you do something wrong that will produce the leak.
This is an important difference. Indeed, it could well be, in the first case, that is the very
annotationobject which is leaked somewhere else in your code. You should check all the flow of execution that Instruments is showing you as stack trace.