I didn't not find leaks on my UIImage
I think I have some leaks caused from my UIImage. In fact, there are lots of images that are downloaded and I think that when I download the new picture, it's showed upper the older and the older aren't dealloc or released...
// 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 c开发者_Go百科ount 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(@"-----------------------");
That code give me that result :
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
-----------------------
Apparently, The image were released and there is only 1, but the older still on the phone's screen.. apparently...
If there are more pictures on the screen, how can I release the older pictures???
Thanks to read my questions!!!
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0,64,320,367);
[self.view addSubview:imageView];
[imageView release];
}
you should release
the allocated imageView
You are alloc imageView and not release it.
So release it after add to view.
[imageView release];
rather than creating a new imageView everytime your connection finishes, you should just set the image property of the imageView
精彩评论