我想我有一些泄漏是由我的UIImage造成的。事实上,有很多被下载的图像。我认为,当我下载新的图片,它的表现上较老的和旧的没有的dealloc或释放...我没有发现我的UIImage泄漏
// Create and posit the UIImage
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
NSLog(@"retain count 1 : %i", [imageView retainCount]);
imageView = [[UIImageView alloc] initWithImage:image];
NSLog(@"retain count 2 : %i", [imageView retainCount]);
//[imageView setImage:image];
//[imageView initWithImage:image];
imageView.frame = CGRectMake(0,64,320,367);
NSLog(@"retain count 3 : %i", [imageView retainCount]);
[self.view addSubview:imageView];
NSLog(@"retain count 4 : %i", [imageView retainCount]);
[imageView release];
NSLog(@"retain count 5 : %i", [imageView retainCount]);
NSLog(@"-----------------------");
该代码给我这一结果:
retain count 1 : 0
retain count 2 : 0
retain count 3 : 1
retain count 4 : 1
retain count 5 : 2
retain count 6 : 1
-----------------------
retain count 1 : 0
retain count 2 : 0
retain count 3 : 1
retain count 4 : 1
retain count 5 : 2
retain count 6 : 1
-----------------------
retain count 1 : 0
retain count 2 : 0
retain count 3 : 1
retain count 4 : 1
retain count 5 : 2
retain count 6 : 1
-----------------------
显然,图像被释放,仅出现1,但仍然较老的手机屏幕上..显然...
如果在屏幕上显示更多的图片,怎么样我可以释放较旧的图片吗?
感谢阅读我的问题!
我已经更新我的代码图像属性! – clement 2011-05-05 12:19:06