ios - Rules for managing CGImageRef memory? -


what rules managing memory cgimagerefs arc? is, can me right documentation?

i getting images photo library , creating uiimage display:

cgimageref newimage = [assetrep fullresolutionimage]; ... uiimage *cloudimage = [uiimage imagewithcgimage:newimage scale:scale orientation:orientation]; 

do need cgimagerelease(newimage)?

i'm getting memory warnings doesn't seem gradual buildup of objects haven't released , i'm not seeing leaks instruments. puzzled am.

no, not need call cgimagerelease() on cgimageref returned alassetrepresentation's convenience methods fullresolutionimage or fullscreenimage. unfortunately, @ current time, documentation , header files these methods not make clear.

if create cgimageref using 1 of cgimagecreate*() functions, own , responsible releasing image ref using cgimagerelease(). in contrast, cgimagerefs returned fullresolutionimage , fullscreenimage appear "autoreleased" in sense not own image ref returned methods. example, try in code:

cgimageref newimage = [assetrep fullresolutionimage]; ... uiimage *cloudimage = [uiimage imagewithcgimage:newimage                         scale:scale orientation:orientation]; cgimagerelease(newimage); 

if run static analyzer, issue following warning cgimagerelease(newimage); line:

incorrect decrement of reference count of object not owned @ point caller

note warning regardless of whether project set use manual reference counting or arc.

in contrast, documentation cgimage method of nsbitmapimagerep, example, makes fact cgimageref returned autoreleased more clear:

cgimage

returns core graphics image object receiver’s current bitmap data.

- (cgimageref)cgimage

return value

returns autoreleased cgimageref opaque type based on receiver’s current bitmap data.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -