多次在cell中加载网络图片后,内存增长,以前资源未释放
NSString *kURL = [NSString stringWithFormat:@"pathxxxxx",[[dict objectForKey:@"id"] intValue]];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(downloadImage:) object:kURL];
NSOperationQueue *queue = [[NSOperationQueue alloc]init];
[queue addOperation:operation];
-(void)downloadImage:(NSString *)url{
NSURL *nsUrl = [NSURL URLWithString:url];
NSData *data = [[NSData alloc]initWithContentsOfURL:nsUrl];
UIImage * image = [[UIImage alloc]initWithData:data];
performSelectorOnMainThread:@selector(updateUI:) withObject:image waitUntilDone:YES];
}
还有就是根据下载好的图片进行重新绘制成指定大小时 ,每绘制一次内存就会增加,而且以前绘制的图片(即当前已不在使用的)好像也没释放掉,不知道为什么?绘制图片调用了如下函数UIGraphicsBeginImageContextWithOptions,drawInRect,UIGraphicsGetImageFromCurrentImageContext , UIGraphicsEndImageContext();