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

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

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

        uiwebview 和巨大的内存丢失

        时间:2023-10-22
        <legend id='0LGHU'><style id='0LGHU'><dir id='0LGHU'><q id='0LGHU'></q></dir></style></legend>
          <tfoot id='0LGHU'></tfoot>
              <tbody id='0LGHU'></tbody>
              <bdo id='0LGHU'></bdo><ul id='0LGHU'></ul>

                <small id='0LGHU'></small><noframes id='0LGHU'>

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

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

                  问题描述

                  我在使用 UIWebViews 时遇到问题,我在这里看到了同样的问题,但没有有用的答案.问题在这里: UIWebView 内存管理 .我会引用它:

                  I have a problem using UIWebViews, I've seen the same question here but there wasn't helpful answer. the question is here: UIWebView memory management . I will quote it:

                  我正在开发一个大量使用 UIWebView 的应用程序.这个应用程序在从我的服务器加载内容时动态生成大量 UIWebView.其中一些 UIWebView 非常大,并且有很多图片.

                  I am developing an application that makes heavy use of UIWebView. This app generates dynamically lots of UIWebViews while loading content from my server. Some of these UIWebViews are quite large and have a lot of pictures.

                  如果我使用仪器检测泄漏,我不会检测到任何泄漏.但是,分配了很多对象,我怀疑这与 UIWebViews 有关.

                  If I use instruments to detect leaks, I do not detect any. However, lots of objects are allocated and I suspect that has to do with the UIWebViews.

                  当 webviews 因为不再需要而释放时,似乎并不是所有的内存都被释放了.我的意思是,在向我的服务器发出请求后,应用程序会创建一个 UITableView 和许多 webviews(仪器说大约 8Mb).当用户点击返回时,所有这些都被释放,但内存使用量仅减少约 2-3 Mb,并在使用应用程序 5-10 分钟后崩溃.

                  When the webviews release because no longer needed, it appears that not all memory is released. I mean, after a request to my server the app creates an UITableView and many webviews (instruments say about 8Mb). When user tap back, all of them are released but memory usage only decrements about 2-3 Mb, and after 5-10 minutes using the app it crashes.

                  我创建了简单的测试应用程序并得到了相同的结果.

                  I have created simple test app and have the same results.

                  这是一个tableView,我正在创建这样的DetailsView:

                  It's a tableView, I'm creating DetailsView like this:

                  DetailsVC *detailViewController = [[DetailsVC alloc] initWithNibName:@"DetailsVC" bundle:nil];
                  detailViewController.n = indexPath.row;
                  [self.navigationController pushViewController:detailViewController animated:YES];
                  [detailViewController release];
                  

                  在 DetailsVC 中,我在 IB 中创建了一个 webView.我像这样加载html:

                  in DetailsVC I have a webView created in IB. I load html like this:

                      NSString *urlAddress;
                  if (self.n == 0)
                  {
                      urlAddress = @"http://www.google.com";
                  }
                  else 
                  {
                      urlAddress = @"http://www.yahoo.com";
                  }
                  
                  NSURL *url = [NSURL URLWithString:urlAddress];
                  
                  NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
                  
                  [self.webView loadRequest:requestObj];
                  

                  我也这样做:

                  - (void)viewDidUnload {
                  self.webView = nil;
                  }
                  

                  就是这样,每次我在 RootViewController 中选择任何 webView 都会丢失 2-3 Mb 的内存,有没有解决这个问题的方法?

                  That's it, every time I choose any webView in RootViewController I'm loosing 2-3 Mb of memory, Is there a solution to this problem?

                  谢谢.

                  推荐答案

                  只需检查以下1.你是否将webview作为属性删除它2. 并将以下代码放入Appdelegate

                  Just check the following 1. Is u make the webview as property remove it 2. And put the following code in didFinishLaunchingWithOptions in Appdelegate

                      NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
                      [NSURLCache setSharedURLCache:sharedCache];
                      [sharedCache release];
                  

                  我想你的问题解决了

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

                  上一篇:两个 UIWebView 有单独的 cookie 存储吗? 下一篇:在 uiwebview 中播放本地视频

                  相关文章

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

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

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