我在分析应用程序时发现内存泄漏
CustomAnnotation *annotationPoint = [[CustomAnnotation alloc] initWithLatitude:store.latitude longitude:store.longitude];
annotationPoint.titleLabel = store.name;
annotationPoint.subtitleLabel = [NSString stringWithFormat:@"%dm", store.distance];
[annotationPoint setEvent:store];
[self.mapView addAnnotation:annotationPoint];
[annotationPoint release];
这是指定为泄漏,annotationPoint.subtitleLabel = [NSString stringWithFormat:@"%dm", store.distance];
标记为100%
我该怎么做才能解决这个问题?
答案 0 :(得分:0)
您是否在CustomAnnotation的dealloc函数中调用[subtitleLabel release]? 在这种情况下,这将解决问题,但是
如上所述:[NSString stringWithFormat]
返回一个自动释放的对象。
这意味着您必须使用autoreleasepool来进行正确的内存管理。