开发者

UIWebview size limit

Everytime I load a html file that is larger than 2MB my开发者_开发问答 app crashes. Is there a limit to how big a web page can be? How can I not crash my app (partial loading?)


When you load 2MB of HTML, the UIWebView has to consume a lot of memory to create a DOM and all of the controls/graphics/etc. to actually show the page. The limit is not the HTML size, but the resulting amount of memory that is needed to display it. Run it in the simulator with the Activity Monitor to see memory consumption

Xcode Instruments: peak RAM of iPhone apps running in Simulator?

You'll need to break down your pages or find another way to do the markup to make the memory smaller. Note that just making the HTML smaller might not help if you need to create the same page.


I bet you're ignoring the memory warnings that are being sent to your UIViewController subclass that is home to your UIWebView.

Uncomment -(void)didReceiveMemoryWarning and emit some NSLog messages from there. You'll probably see that the phone is frantically trying to get your attention about a low-memory condition. And when you don't respond by lowering memory use, it kills you.

What you want to do in that method is free any resources you're holding on to--images, big chunks of data, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜