一、 Block循环引用问题
__weak typeof(self) weakself = self;
二、Delegate循环引用问题
@property (nonatomic,weak) id <customerDelegate>delegate;
三、NStimer训循环引用
定时器使用完毕时需要将其停止并滞空
- (void)cleanTimer {
[ _timer invalidate ];
_timer = nil;
}
该方法在NSTimer所咋当前类中dealloc方法中调用无效
四、地图类处理
- (void) clearMapView {
self.mapView = nil;
self.mapView.delegate = nil;
self.mapView.showsUserLocation = NO;
[self.mapView removeAnnotations: self.annotations];
[self.mapView removeOverlays: self.overlays];
[self.mapView setCompassImage: nil];
}
五、大次数循环内存暴涨问题
举例:
for (int i =0; i <100000; i++) {
NSString *string = @"Abc";
string = [stringlowercaseString];
string = [string stringByAppendingString:@"xyz"];
NSLog(@"%@",string);
}
修改为:
for (int i =0; i < 100000; i++) {
@autoreleasepool {
NSString *string = @"Abc";
string = [string lowercaseString];
string = [string stringByAppendingString:@"xyz"];
NSLog(@"%@",string);
}
}
网友评论