• <bdo id='ua4hN'></bdo><ul id='ua4hN'></ul>

    <tfoot id='ua4hN'></tfoot>

    1. <i id='ua4hN'><tr id='ua4hN'><dt id='ua4hN'><q id='ua4hN'><span id='ua4hN'><b id='ua4hN'><form id='ua4hN'><ins id='ua4hN'></ins><ul id='ua4hN'></ul><sub id='ua4hN'></sub></form><legend id='ua4hN'></legend><bdo id='ua4hN'><pre id='ua4hN'><center id='ua4hN'></center></pre></bdo></b><th id='ua4hN'></th></span></q></dt></tr></i><div id='ua4hN'><tfoot id='ua4hN'></tfoot><dl id='ua4hN'><fieldset id='ua4hN'></fieldset></dl></div>

      <small id='ua4hN'></small><noframes id='ua4hN'>

    2. <legend id='ua4hN'><style id='ua4hN'><dir id='ua4hN'><q id='ua4hN'></q></dir></style></legend>
    3. UIWebView 占用大量内存

      时间:2023-10-22

        <bdo id='QZXvt'></bdo><ul id='QZXvt'></ul>
        <legend id='QZXvt'><style id='QZXvt'><dir id='QZXvt'><q id='QZXvt'></q></dir></style></legend>
        • <i id='QZXvt'><tr id='QZXvt'><dt id='QZXvt'><q id='QZXvt'><span id='QZXvt'><b id='QZXvt'><form id='QZXvt'><ins id='QZXvt'></ins><ul id='QZXvt'></ul><sub id='QZXvt'></sub></form><legend id='QZXvt'></legend><bdo id='QZXvt'><pre id='QZXvt'><center id='QZXvt'></center></pre></bdo></b><th id='QZXvt'></th></span></q></dt></tr></i><div id='QZXvt'><tfoot id='QZXvt'></tfoot><dl id='QZXvt'><fieldset id='QZXvt'></fieldset></dl></div>
          <tfoot id='QZXvt'></tfoot>

            <tbody id='QZXvt'></tbody>

              <small id='QZXvt'></small><noframes id='QZXvt'>

              • 本文介绍了UIWebView 占用大量内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在我的应用程序中,当我使用任何网站 url 加载 UIWebView 时,内存从 30mb 跳到大约 140mb.我正在使用 ARC

                In my app when i load UIWebView with any Website url the memory jumps from 30mb to around 140mb. I am using ARC


                当关闭包含 UIWebView 的 UIWebViewController[Viewcontroller] 时,它不会释放内存.任何人都可以帮助我如何解决这个内存问题,还请在 ARC


                and when dismissing the UIWebViewController[Viewcontroller which contains UIWebView], it doesnt releases the memory. Can any body help me how to solve this memory issues as well as please also provide me pointers of memory bestpractices in ARC

                用于加载网页:-

                NSURL *nsurl=[NSURL URLWithString:self.url];
                    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
                    [webview loadRequest:nsrequest];
                

                对于关闭视图控制器:-

                FOr Dismissing the Viewcontroller:-

                [self dismissViewControllerAnimated:YES completion:^{
                    webview.delegate=nil;
                    webview=nil;
                }];
                

                在此先感谢 :)

                推荐答案

                哇,今天我们也遇到了这个问题.当我们尝试加载包含大量图片或巨大网页的网页时,很容易崩溃.我们还发现内存使用了将近200M.

                wow, today we also meet this problem. when we try to load a web page which contain lots pictures or a huge web page, it's easy to crash. we also find the memory used nearly 200M.

                最后我们发现我们可以移除网页视图的内存缓存

                finally we find that we could remove the memory cache of web view

                [[NSURLCache sharedURLCache] removeAllCachedResponses];
                

                您可以在收到内存警告时尝试.或者你可以在 dealloc 方法中调用它.

                you can try it when you receive memory warning. or you can call it in the dealloc method.

                如果还是有问题,尝试通过调用限制内存缓存大小

                if it still have some problems, try to limit the memory cache size by call

                [[NSURLCache sharedURLCache] setMemoryCapacity:size]
                

                祝你好运!

                这篇关于UIWebView 占用大量内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:iOS 6 - UIWebView loadHTMLString 无法正常工作 下一篇:两个 UIWebView 有单独的 cookie 存储吗?

                相关文章

              • <i id='yR1H5'><tr id='yR1H5'><dt id='yR1H5'><q id='yR1H5'><span id='yR1H5'><b id='yR1H5'><form id='yR1H5'><ins id='yR1H5'></ins><ul id='yR1H5'></ul><sub id='yR1H5'></sub></form><legend id='yR1H5'></legend><bdo id='yR1H5'><pre id='yR1H5'><center id='yR1H5'></center></pre></bdo></b><th id='yR1H5'></th></span></q></dt></tr></i><div id='yR1H5'><tfoot id='yR1H5'></tfoot><dl id='yR1H5'><fieldset id='yR1H5'></fieldset></dl></div>

                      <bdo id='yR1H5'></bdo><ul id='yR1H5'></ul>
                    <legend id='yR1H5'><style id='yR1H5'><dir id='yR1H5'><q id='yR1H5'></q></dir></style></legend>

                  1. <tfoot id='yR1H5'></tfoot>

                  2. <small id='yR1H5'></small><noframes id='yR1H5'>