我想將所有照片從資產保存到某個文件夾。這樣做循環:Objective-C imageWithCGImage內存泄漏
ALAssetRepresentation *representation = [asset defaultRepresentation];
CGImageRef imageRef = [representation fullResolutionImage];
ALAssetOrientation orientation = [representation orientation];
UIImage *image = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:(UIImageOrientation)orientation];
CGFloat compressionQuality = 1.0;
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(image, compressionQuality)];
[imageData writeToFile:path atomically:YES];
CGImageRelease(imageRef);
我已啓用自動引用計數。此代碼位於autorelease池內。它有一個CGImageRef對象的內存泄漏。如果我將製作
CGImageRelease(imageRef);
CGImageRelease(imageRef);
兩次沒有內存泄漏。爲什麼?任何人都可以幫助我?
這救了我的命。 –