Why UIWebView Eating so many Memory?

社会主义新天地 提交于 2019-12-07 16:50:02

问题


I'm using a UIWebView to load a pure Text HTML page for my iPad app. The size of the HTMP page is only 40KB. But when I use the instrument to monitor the memory use for loading the UIWebView, I found down it consumes like 20MB memory, if I scroll the web view, the memory is even getting higher. Finally I get a level 1 memory warning.

Could anyone help me with this? How could I reduce the memory for this? (I need to use the HTML to show the text here).

 NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"SPC"];
 NSURL *url = [NSURL fileURLWithPath:htmlPath];
 NSURLRequest *request = [NSURLRequest requestWithURL:url];
 [webView loadRequest:request];

回答1:


htmlPath url request

release all of them after this line

[webView loadRequest:request];

then release webview in dealloc and use webview as ivar



来源:https://stackoverflow.com/questions/4079452/why-uiwebview-eating-so-many-memory

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