Why UIWebView Eating so many Memory?

2019-05-10 09:17发布

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条回答
三岁会撩人
2楼-- · 2019-05-10 09:53

htmlPath url request

release all of them after this line

[webView loadRequest:request];

then release webview in dealloc and use webview as ivar

查看更多
登录 后发表回答