UIWebView memory consumption is too high, crashes, memory overflow, the need for friends can refer to.
In the project where the emulator runs UIWebView read Local magazine, no problem, the real machine test often crashes with memory overflow.
I checked the data. Because of the memory leak caused by JS in HTML, the "Webkitcachemodelpreferencekey" is set to 1 each time a connection is opened.
UIWebView Increase
-(void) Webviewdidfinishload: (UIWebView *) WebView {
[[Nsuserdefaults Standarduserdefaults] setinteger:0 forkey:@ "Webkitcachemodelpreferencekey"];
}
Solve the problem
Reason:
Your is going to has a big memory usage and leak a lot of data!
But there was a hack to solve this problem:revert what was done when you open a link.
In fact, the key property which leads to this leak is the Webkitcachemodelpreferencekey application setting. And when you open a link in a UIWebView, this property is automatically set to the value "1". So, the solution are to set it back to 0 everytime you open a link. Easily do the adding a uiwebviewdelegate to your UIWebView:
-(void) Webviewdidfinishload: (UIWebView *) WebView {
[[Nsuserdefaults Standarduserdefaults] setinteger:0 forkey:@ "Webkitcachemodelpreferencekey"];
}
So is going to has much less crash due to "low Memory":)
The number of crashes is much reduced.
Foreign small Brother original address: http://blog.techno-barje.fr//post/2010/10/04/UIWebView-secrets-part1-memory-leaks-on-xmlhttprequest/
UIWebView memory usage, crashes, memory overflow