Memory leak with UIWebView

好久不见. 提交于 2019-12-05 04:57:30

I was having the same problem and switched to the new WKWebView and it immediately solved all of the memory leak issues I was seeing. WKWebView shares many of the same call names from UIWebView so all I had to do on my project is switch over all my `UIWebView' objects to 'WKWebView' and the memory leaks went away.

Remember to import the WebKit into your project and know that is is only available on iOS8.

Apple Documentation

I had a similar problem, having users testing the app by previewing images in UIWebView. The app would crash after N previews. Using Apple Instruments tool with Allocations profiling template. From the tool, I was able to select the following Allocation Lifespan: "Created & Persistent". Further observations is when previewing the same file multiple times, Persistent Bytes (Based on apple definition, this is the number of bytes that have been allocated, but not released.) for ImageIO_jpeg_Data keep growing in doubles, this is true for any other image type.

A resolution for this is to use UIImageView from apple as a separate previewer for Images, this cause no memory leaks at all when previewing images.

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