Analyzer报告以下代码泄漏

han*_*Dev 4 iphone memory-management objective-c analyzer ios

Analyzer报告以下代码可能存在内存泄漏.任何人都可以对此有所了解吗?我正在发布已经分配的注释.

  -(AddressAnnotation *)addAdress:(NSString*)placeTitle SubTitle:(NSString*)placeSubTitle Coordinate:(CLLocationCoordinate2D)coord withId:(NSInteger) placeId{
        AddressAnnotation *annotation = [[AddressAnnotation alloc] initWithCoordinate:coord];
        annotation.placeTitle = placeTitle;
        annotation.placeSubTitle = placeSubTitle;
        annotation.museumId = placeId;
        [mapView addAnnotation:annotation]; 
        return annotation;

        [annotation release];
    }
Run Code Online (Sandbox Code Playgroud)

All*_*ian 7

你在回归后释放,所以永远不会被召唤.另请注意,地图视图会在您添加注释时保留注释.


con*_*are 5

更改

return annotation;
[annotation release];
Run Code Online (Sandbox Code Playgroud)

return [annotation autorelease];
Run Code Online (Sandbox Code Playgroud)