UIWebView The memory occupation is too high, crash, memory overflow, if you need to refer to the following.
The project is running UIWebView on the simulator to read local magazines, no problem, but the real machine test often crashes with memory overflow.
After checking the data, the memory leak is caused by the js in Html, and the “WebKitCacheModelPreferenceKey” is set to 1 every time a connection is opened.
UIWebView add
– (void)webViewDidFinishLoad:(UIWebView *)webView {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@”WebKitCacheModelPreferenceKey”];
}
Solving the problem
Cause:
Your are going to have a big memory usage and leak a lot of data!
But there is a hack to solve this problem: revert what is 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 is to set it back to 0 everytime you open a link. You may easily do this by adding a UIWebViewDelegate to your UIWebView :
– (void)webViewDidFinishLoad:(UIWebView *)webView {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@”WebKitCacheModelPreferenceKey”];
}
So are you going to have much less crash due to “Low Memory” 🙂
The number of crashes is much reduced.
http://blog.techno-barje.fr//post/2010/10/04/UIWebView-secrets-part1-memory-leaks-on-xmlhttprequest/
Similar Posts:
- Block Wild Pointer crash: Thread 1:EXC_BAD_ACCESS(code=1,address=0x10)
- [Solved] WordPress Error: Allowed memory size of 134217728 bytes exhausted
- Error log: resource leak: ‘xxx’ is never closed (precautions for scanner class)
- [Five Method to Solve] android webpage err_unknown_url_scheme
- Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
- Android WebView monitors and rewrites window.history.go (- 1) method call
- [Solved] Hive export MYSQL Error: Container [pid=3962,containerID=container_1632883011739_0002_01_000002] is running 270113280B beyond the ‘VIRTUAL’ memory limit.
- java.net.SocketException: No buffer space available
- R6010 -abort() has been called error analysis and solutions
- Rabbitmq startup error kernel PID terminated [How to Solve]