为什么UIWebView吃了那么多内存? [英] Why UIWebView Eating so many Memory?

查看:83
本文介绍了为什么UIWebView吃了那么多内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIWebView为iPad应用程序加载纯文本HTML页面. HTMP页面的大小仅为40KB.但是,当我使用该工具监视用于加载UIWebView的内存使用时,我发现它消耗的内存约为20MB,如果滚动Web视图,则该内存甚至会更高.最终,我收到了1级内存警告.

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.

有人可以帮我吗?我该如何减少内存呢? (我需要使用HTML在此处显示文本).

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];

推荐答案

htmlPath 网址 请求

htmlPath url request

在此行之后释放所有这些

release all of them after this line

[webView loadRequest:request];

[webView loadRequest:request];

然后在dealloc中释放webview并将webview用作ivar

then release webview in dealloc and use webview as ivar

这篇关于为什么UIWebView吃了那么多内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆