<tfoot id='RDDv5'></tfoot>

    <legend id='RDDv5'><style id='RDDv5'><dir id='RDDv5'><q id='RDDv5'></q></dir></style></legend>

    1. <small id='RDDv5'></small><noframes id='RDDv5'>

        <bdo id='RDDv5'></bdo><ul id='RDDv5'></ul>
      <i id='RDDv5'><tr id='RDDv5'><dt id='RDDv5'><q id='RDDv5'><span id='RDDv5'><b id='RDDv5'><form id='RDDv5'><ins id='RDDv5'></ins><ul id='RDDv5'></ul><sub id='RDDv5'></sub></form><legend id='RDDv5'></legend><bdo id='RDDv5'><pre id='RDDv5'><center id='RDDv5'></center></pre></bdo></b><th id='RDDv5'></th></span></q></dt></tr></i><div id='RDDv5'><tfoot id='RDDv5'></tfoot><dl id='RDDv5'><fieldset id='RDDv5'></fieldset></dl></div>
    2. 在 UIWebView 中调用 loadRequest 时出现 GeneralBlock-56 内存泄漏

      时间:2023-11-09

    3. <small id='fcFzJ'></small><noframes id='fcFzJ'>

        <legend id='fcFzJ'><style id='fcFzJ'><dir id='fcFzJ'><q id='fcFzJ'></q></dir></style></legend>
          <tfoot id='fcFzJ'></tfoot>
          1. <i id='fcFzJ'><tr id='fcFzJ'><dt id='fcFzJ'><q id='fcFzJ'><span id='fcFzJ'><b id='fcFzJ'><form id='fcFzJ'><ins id='fcFzJ'></ins><ul id='fcFzJ'></ul><sub id='fcFzJ'></sub></form><legend id='fcFzJ'></legend><bdo id='fcFzJ'><pre id='fcFzJ'><center id='fcFzJ'></center></pre></bdo></b><th id='fcFzJ'></th></span></q></dt></tr></i><div id='fcFzJ'><tfoot id='fcFzJ'></tfoot><dl id='fcFzJ'><fieldset id='fcFzJ'></fieldset></dl></div>
              <tbody id='fcFzJ'></tbody>
              <bdo id='fcFzJ'></bdo><ul id='fcFzJ'></ul>
                本文介绍了在 UIWebView 中调用 loadRequest 时出现 GeneralBlock-56 内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在开发一个 iPad 应用程序,并且一直在使用 XCode 4 中的 Instruments 对其进行分析.我正在对实际设备本身进行分析.已安装 iOS 4.3.

                I'm working on an IPad app and have been profiling it using Instruments in XCode 4. I'm profiling on the actual device itself. iOS 4.3 is installed.

                仪器告诉我有一些内存泄漏,泄漏的对象主要是 GeneralBlock-56 和一些 GeneralBlock-1024/GeneralBlock-8192 的.有趣的是,只有当我在应用程序中嵌入的 UIWebView 中加载 URL 时才会报告这些泄漏.如果我注释掉 loadRequest 调用,这些泄漏就会消失.这种行为始终可以重现.

                Instruments tells me I have some memory leaks, the leaked objects being mainly GeneralBlock-56 ones and some GeneralBlock-1024/GeneralBlock-8192 ones. The interesting thing is that these leaks are reported only when I load up a URL in a UIWebView embedded in my app. If I comment out the loadRequest call, these leaks go away. This behavior is consistently reproducible.

                loadRequest() 调用如下所示:

                The loadRequest() calls looks like this:

                [webPage loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://slashdot.org"]]];
                

                顺便说一句,我没有为此 UIWebView 指定任何委托.泄漏没有显示任何责任库/责任框架,并且最右边的框架中没有扩展细节.

                I'm not specifying any delegates for this UIWebView, by the way. The leaks do not show any Responsible Library/Responsible Frame and there is no Extended Detail in the rightmost frame.

                我试图摆弄 NSURLCache 设置,如下所示:

                I have tried to fiddle around with the NSURLCache settings, like so:

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

                这减少了一些 GeneralBlock 内存泄漏,但仍然存在一些.非常欢迎对此行为的任何见解...谢谢!

                This reduces a few of the GeneralBlock memory leaks, but some still remain. Any insights on this behavior are very welcome...thanks!

                推荐答案

                这是我使用 Apple Developer Bug Reporting 工具提交的错误报告.在我的情况下,这似乎是导致内存泄漏的大问题之一.

                This is a bug report I filed with the Apple Developer Bug Reporting tool. This seemed to be one of the big issues causing the memory leak in my case.

                总结:将格式不正确的 NSURL 传递给 NSData dataWithContentsOfURL:导致 createCanonicalURL() 方法内存泄漏.

                复制步骤

                在任何简单的项目中,将以下几行放入控制器中,例如,在 loadView: 或 viewDidLoad: 方法中.:

                In any simple project, put the following lines in your controller, for example, in loadView: or viewDidLoad: methods.:

                NSURL* u = [NSURL URLWithString:@"http:/portalqa01:70/Images/Leading%20out%20of%20a%20Downturn%20-%20Article%20Illustration%20-%20Large_tcm137-38905.gif"];
                    NSData* data = [NSData dataWithContentsOfURL:u options:0 error:nil];
                

                请注意,URL 在http:"之后只有一个斜杠,而不是通常的两个.

                Note that the URL has only a single slash after "http:" instead of the customary two.

                预期结果:不应该有任何内存泄漏.

                Expected Results: There shouldn't be any memory leak.

                实际结果:Instruments 显示内存泄漏.

                Actual Results: Instruments shows a memory leak.

                回归:这只发生在一些格式错误的 URL 上,上面的 URL 是一个具体的例子.像http:/blah/blah.png"这样的 URL 不会导致泄漏.用于重现此情况的环境是:

                Regression: This only occurs for some malformed URLs, the URL above is a specific example. A URL like "http:/blah/blah.png" will not cause a leak. The environments used to reproduce this were:

                • iPad 4.3 模拟器
                • 装有 iOS 4.3.1 的 iPad 2

                注意事项:堆栈跟踪如下:

                Notes: The stack trace is as below:

                   0 CFNetwork createCanonicalURL
                   1 CFNetwork HTTPProtocol::_createMutableCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
                   2 CFNetwork HTTPProtocol::_createCanonicalRequest(__CFAllocator const*, _CFURLRequest const*, void const*)
                   3 CFNetwork HTTPProtocol::copyCanonicalRequest()
                   4 CFNetwork URLConnectionLoader::copyProtocolCanonicalRequest()
                   5 CFNetwork URLConnectionClient::getRequestForTransmission(unsigned char, _CFURLResponse*, _CFURLRequest const*, __CFError**)
                   6 CFNetwork URLConnectionClient::_clientWillSendRequest(_CFURLRequest const*, _CFURLResponse*, URLConnectionClient::ClientConnectionEventQueue*)
                   7 CFNetwork URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long)
                   8 CFNetwork URLConnectionClient::processEvents()
                   9 CFNetwork MultiplexerSource::perform()
                  10 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
                  11 CoreFoundation __CFRunLoopDoSources0
                  12 CoreFoundation __CFRunLoopRun
                  13 CoreFoundation CFRunLoopRunSpecific
                  14 CoreFoundation CFRunLoopRunInMode
                  15 CFNetwork CFURLConnectionSendSynchronousRequest
                  16 Foundation +[NSURLConnection sendSynchronousRequest:returningResponse:error:]
                  17 Foundation -[NSData(NSData) initWithContentsOfURL:options:error:]
                  18 Foundation +[NSData(NSData) dataWithContentsOfURL:options:error:]
                  19 MemLeakTester -[MemLeakTesterViewController viewDidLoad] /Users/admin/IPadSpikes/MemLeakTester/MemLeakTester/MemLeakTester/MemLeakTesterViewController.m:36
                  20 UIKit -[UIViewController view]
                  21 UIKit -[UIWindow addRootViewControllerViewIfPossible]
                  22 MemLeakTester -[MemLeakTesterAppDelegate application:didFinishLaunchingWithOptions:] /Users/admin/IPadSpikes/MemLeakTester/MemLeakTester/MemLeakTester/MemLeakTesterAppDelegate.m:27
                  23 UIKit -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
                  24 UIKit -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
                  25 UIKit -[UIApplication handleEvent:withNewEvent:]
                  26 UIKit -[UIApplication sendEvent:]
                  27 UIKit _UIApplicationHandleEvent
                  28 GraphicsServices PurpleEventCallback
                  29 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
                  30 CoreFoundation __CFRunLoopDoSource1
                  31 CoreFoundation __CFRunLoopRun
                  32 CoreFoundation CFRunLoopRunSpecific
                  33 CoreFoundation CFRunLoopRunInMode
                  34 UIKit -[UIApplication _run]
                  35 UIKit UIApplicationMain
                  36 MemLeakTester main /Users/admin/IPadSpikes/MemLeakTester/MemLeakTester/MemLeakTester/main.m:14
                  37 MemLeakTester start
                

                <小时>

                堆栈跟踪结束


                STACK TRACE END

                这篇关于在 UIWebView 中调用 loadRequest 时出现 GeneralBlock-56 内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:WKWebView 在设备上显示空白,在模拟器上工作 下一篇:防止 UIWebView 重新定位输入字段

                相关文章

                  1. <small id='Xv0VF'></small><noframes id='Xv0VF'>

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

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