1. When the memory warning is received, clear the cached content.
-(void) applicationdidreceivememorywarning: (uiapplication*) application
{
[[Nsurlcache Sharedurlcache] removeallcachedresponses];
}
2. When releasing the UIWebView
_webview.delegate = nil;
[_webview loadhtmlstring:@ "" Baseurl:nil];
[_webview stoploading];
[_webview Removefromsuperview];
[[Nsurlcache Sharedurlcache] removeallcachedresponses];
[_webview release];
3. In the Webviewdidfinishload method, set the following:
[[Nsuserdefaults standarduserdefaults] setinteger:0 forkey:@ "Webkitcachemodelpreferencekey"];
[[Nsuserdefaults standarduserdefaults] setbool:no forkey:@ "webkitdiskimagecacheenabled"];//self-added, Not mentioned in the original.
[[Nsuserdefaults standarduserdefaults] Setbool:no forkey:@ " Webkitofflinewebapplicationcacheenabled "];//himself added, the original is not mentioned.
[[Nsuserdefaults standarduserdefaults] synchronize];
UIWebView Memory leak Problem Solving method