Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is it appropriate to release CGImageRef?

When XCode analyzes my code, it finds potential memory leaks. I use ARC, but I learned that ARC doesn't handle C types. Since I use CGImageRef in order to create UIImage with it and assign to UIImageView.image property, When is it appropriate to release CGImageRef? Can I release it right after I create a new UIImage with it? If I release the CGImageRef, then does it make my UIImage instance also invalid?

like image 439
neo Avatar asked Mar 19 '26 02:03

neo


1 Answers

UIImageView retains the image property (if it needs it) or it copies it - whatever. Once you have set that property, you can then immediately release the CGImageRef.

like image 120
David H Avatar answered Mar 20 '26 14:03

David H



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!