ios - Potential leak of an object stored into CGImageRef -
ios - Potential leak of an object stored into CGImageRef -
running code under xcode analyze i’ve stumbled next block
- (uiimage *)imagewithfilter:(cifilter *)filter { cicontext *ctx = [cicontext contextwithoptions:nil]; cgimageref imageref = [ctx createcgimage:filter.outputimage fromrect:cgrectmake(0, 0, self.size.width, self.size.height)]; homecoming [uiimage imagewithcgimage:imageref]; }
xcode complains potential memory leak:
what going on? , how go fixing it?
the next looks fix, still not sure if best way of handling on retained reference?
- (uiimage *)imagewithfilter:(cifilter *)filter { cicontext *ctx = [cicontext contextwithoptions:nil]; cgimageref imageref = [ctx createcgimage:filter.outputimage fromrect:cgrectmake(0, 0, self.size.width, self.size.height)]; uiimage *image = [uiimage imagewithcgimage:imageref]; cgimagerelease(imageref); homecoming image; }
ios objective-c xcode memory-leaks automatic-ref-counting
Comments
Post a Comment