我遇到的问题是,相对较大的图像似乎永远不会从内存中释放出来(大小为1MB~5MB).当用户滚动浏览一组图像时,将调用以下代码块.大约15张图像后,应用程序将崩溃.有时候,"didReceiveMemoryWarning"被调用,有时doesn't - 应用程序只会崩溃,停止,退出调试,并在任何一行代码不会停止 - 什么都没有.我假设当设备内存不足时会发生这种情况?另一个问题是'dealloc'似乎永远不会被称为子类'DownloadImageOperation'.有任何想法吗?
获取和设置图像:
//Calling this block of code multiple times will eventually cause the
// application to crash
//Memory monitor shows real memory jumping 5MB to 20MB increments in instruments.
//Allocations tool shows #living creeping up after this method is called.
//Leaks indicate something is leaking, but in the 1 to 5 kb increments. Nothing huge.
DownloadImageOperation * imageOp = [[DownloadImageOperation alloc] initWithURL:imageURL localPath:imageFilePath];
[imageOp setCompletionBlock:^(void){
//Set the image in a UIImageView in the open UIViewController.
[self.ivScrollView …Run Code Online (Sandbox Code Playgroud)