AFNetworking/AFNetworking — comment on commit 0e93cf0840198c93f416c7386e8d136079ed2a0e
File:  line 0
By zbowling:

This may be a premature optimization (which in a library I'm not sure if one could exists since you can't profile the user's needs), but If you can get around using GCImage, the UIImage class (which is a class cluster with a mess load of optimizations) can hold off decoding the NSData right away and has a chance of not copying it. I know from duplicating the behavior in my Chameleon fork.

With this solution, you always will end up forcing the image to decode right then. The good thing is that [UIImage imageWithCGImage ... ] will give you class that just proxies to the CGImage where it does the transformations when it's actually drawn the first time (the same when you use [UIImage imageWithCapInsets... etc which give you a 3 patch or a 9 patch UIImage).

If you look at my method, I put some ifs around the first UIImage to just see if it's ok at that point or not and if it is, just short cut before going ahead and creating a second UIImage.