Converting an UIview unto UIimage causing memory leak

你离开我真会死。 提交于 2019-12-03 04:58:01

There is no memory leak apparent in the code snippet you provided. That operation could not be performed on a background thread because of UIGraphicsBeginImageContext(), so you should have an NSAutoreleasePool in place (the return value of UIGraphicsGetImageFromCurrentContext() is autoreleased). Without further information, its impossible to tell where the memory leak could be - I suggest you look at whatever objects eventually own the viewImage object and make sure you are properly releasing the UIImage if you retain it.

Heberti Almeida

Use drawViewHierarchyInRect:afterScreenUpdates: instead of renderInContext: it is 15x faster.

You can see the comparison on this article.

Also, I have created a Swift extension for doing this: https://stackoverflow.com/a/32042439/517707

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!