Memory - NSConcreteDatasử dụng NSData trong iPhone
// to set tip - photo in photo frame
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:pathOfThumbNail]];
UIImage *cellThumbImg;
if([data length]>0){ cellThumbImg=[UIImage imageWithData:data];} else { cellThumbImg=[UIImage imageNamed:@"130X90.gif"]; }
UIImageView *imgView=[[UIImageView alloc]initWithImage:cellThumbImg]; imgView.frame=photoFrame;
(cellThumbImg.size.height>=58 || cellThumbImg.size.width>=58) ? [imgView setContentMode:UIViewContentModeScaleToFill] : [imgView setContentMode:UIViewContentModeCenter] ;
[cell.contentView addSubview:imgView];
[imgView release];
câu hỏi của tôi rất giống nhiều cho câu hỏi này,
iPhone - Memory Leak - NSData dataWithContentsOfUrl & UIWebView
Thậm chí, tôi đã thêm mã sau đây để tôi Ứng dụng đã hoàn thành Launching, đưa ra dưới đây. Mã sau đây để thiết lập bộ nhớ sharedCache với dung lượng bằng không. Nó gần như sẽ loại bỏ rò rỉ NSConcreteData trong ứng dụng của tôi. Tuy nhiên rò rỉ bộ nhớ.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
[window makeKeyAndVisible];
}
tôi không thể tìm thấy giải pháp nào cho loại câu hỏi này từ tràn ngăn xếp.
Nếu bạn có thể trả lời, tôi sẽ biết ơn bạn.
Xin cảm ơn trước.
Tôi đã theo dõi cách thức như @Bkaenk & @epatelsaid. Tuy nhiên có cùng một vấn đề, như câu hỏi sau đây. http://stackoverflow.com/questions/280053/iphone-memory-leak-nsdata-datawithcontentsofurl-uiwebview –