UIWebView memory management

后端 未结 4 980
轮回少年
轮回少年 2020-12-15 19:19

I have a problem with memory management.

I am developing an application that makes heavy use of UIWebView. This app generates dynamically lots of UIWebViews while lo

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 19:51

    This isn't a solution, but a possible explanation of the issues you're facing.

    I had memory problems with an app I worked on. It consisted of (in effect) a scroll view, containing 3 full screen sized web views. Each webview's content size was multiple screens, say 10 on average.

    When you load a webview, the whole view is rendered in memory. SO, aside from the memory used to load the images and other data (the stuff you see in the Allocations instrument), the web view itself uses memory when it's rendered that you have no control over.

    So, for example, a 768x1024 webview, with 10 pages of content would use

    768 * 1024 * 10 (pages) * 4 (bits per pixel) = 31,457,280 = 30MB.

    Multiply by 3 web views, and that's 90MB used on top of memory that the app allocated directly.

    You can get a feel for how much memory is being used like this in Instruments, using the VM Tracker instrument.

提交回复
热议问题