一、OC里面包含的一些C库函数,比如在CoreGraphics中的一些C函数:CGContextRelease
CGContextRef context =
CGBitmapContextCreate(
NULL, target_w, target_h,
8,
0, rgb, bmi);
CGColorSpaceRelease
(rgb);
UIImage *pdfImage =
nil;
if (context !=
NULL)
{
CGContextDrawPDFPage
(context, page);
CGImageRef imageRef =
CGBitmapContextCreateImage(context);
CGContextRelease
(context);
pdfImage = [
UIImage
imageWithCGImage
:imageRef scale
:screenScale orientation
:UIImageOrientationUp
];
CGImageRelease(imageRef);
}
else
{
CGContextRelease
(context);
}
二、使用Block注意循环引用,导致无法释放,retain等问题
__block
NSBlockOperation
*operation = [[NSBlockOperation
alloc
]
init
];
__weak
typeof
(self
)weakSelf = self
;
__weak
typeof(operation)weakOp = operation;
MMVoidBlock thumbnailOperationBlock = ^ {
if (!weakOp.
isCancelled)
{
workerBlock();
}
[weakSelf.
thumbnailOperationList
removeObjectForKey
:key];
};
[operation
addExecutionBlock:thumbnailOperationBlock];
老外讲的比较详细,传送门: http://conradstoll.com/blog/2013/1/19/blocks-operations-and-retain-cycles.html