1

In my app, I plan to capture and heavily-process images (with CPU) from camera and displaying them on the screen along with the preview. Currently, I convert the processed the bitmaps into UIImages and display them through a UIImageView by something like

UIImage* newUIIMage = [self convertBitmapToUIIMage];
myUIIMageView.image = newUIImage;

And there is steady memory leak. When I commented out the second line and replaced it with saving the UIImage to storage, the leak is fully plugged up. When I tested the code in instruments, it seems the leak comes from something like "alligned_malloc" which is not called by me ( I'm sorry that I do not have the screenshots now, coming later). I have tried some codes else where like (iphone) UIImageView setImage: leaks? but it seems out-dated and the methods like "release" and "autorelease" are not callable.

Any explanations and suggestions? I have full control of the pixels so it is fine if I have to use a different approach to display the images. Much appreciated!

Community
  • 1
  • 1
Jason M
  • 411
  • 5
  • 19
  • In any case, here is brute fix: display a deep copy of the UIImage by changing the code to UIImage* newUIImage = [self convertBitmapToUIIMage]; UIImage newUIImageDeepCopy = [UIImage imageWithCGImage:[newUIImage CGImage]]; myUIIMageView.image = newUIImageDeepCopy; – Jason M Nov 15 '16 at 01:11

0 Answers0