I am building an app with Cocos3D in need of relatively a lot of screenshot in action:
imgRef = tmpDrawingVisitor.renderSurface.createCGImage;
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docDir = [paths objectAtIndex:0];
imgPath = [docDir stringByAppendingPathComponent: [[NSProcessInfo processInfo] globallyUniqueString]];
_flippingpath = [imgPath stringByAppendingPathExtension:@"png"];
//UIImage* uiImg= [UIImage imageWithCGImage: imgRef];
uiImgprep= [UIImage imageWithCGImage: imgRef];
//UIImage* uiImg= [UIImage imageWithCGImage: imgRef scale:0.5 orientation: UIImageOrientationUp];
uiImg = [self imageWithImage:uiImgprep scaledToSize:CGSizeMake(512.0, 384.0)];
imgData = UIImagePNGRepresentation(uiImg);
[imgData writeToFile: _flippingpath atomically: YES];
What I do is taking a screenshot and save it down to Document folder. After that map it in a CCSprite to animate it like book flipping.
The code works fine, however the memory accumulatively adding up (each time about 12 Mb) and up to a point memory will overload.
How can I manage the memory in this case? I am developing in IOS 7.1.1, which it is already ARC.