Search code examples
iphoneuikituiwebview

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?)


Solution

  • 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.