Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does UIWebView leak memory?

If your iPhone app uses a UIWebView, and loads many pages with large images, you may find that you are leaking memory. Can this be resolved?

like image 911
Chris Lundie Avatar asked Mar 15 '09 19:03

Chris Lundie


2 Answers

Try adding

[webView loadHTMLString: @"" baseURL: nil];

right before you release the webview. For a leak in 4.2.1 relating to displaying a PDF in a UIWebView this solves most of the leak problems for me.

like image 70
Dad Avatar answered Nov 15 '22 21:11

Dad


It is a known problem.

Marco Arment mentions the leak here. http://blog.instapaper.com/post/60628543

There isn't a lot you can do. One option in to "intercept" the html try to truncate parts that you don't need. Obviously, this won't likely work for a general purpose webview.

In the meantime, you may just have to wait for an update from Apple.

like image 32
amattn Avatar answered Nov 15 '22 22:11

amattn