GeneralBlock-56 memory leak when calling loadRequest in UIWebView

I am working on an iPad application and profile it using tools in Xcode 4. I profile myself on the device itself. iOS 4.3 installed.

The tools tell me that I have some memory leaks, leaked objects mostly GeneralBlock-56and some GeneralBlock-1024/ GeneralBlock-8192. Interestingly, these leaks are only reported when loading the URL into the UIWebView embedded in my application. If I comment on the call loadRequest, these leaks will disappear. This behavior is consistently reproducible.

The calls to loadRequest () are as follows:

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

I don't set any delegates for this UIWebView, by the way. Leaks do not show any responsible library / responsible frame, and there is no extended detail in the far right frame.

I tried messing with NSURLCache settings, for example:

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

This reduces some GeneralBlock memory leaks, but some remain. Any ideas on this behavior are very welcome ... thanks!

+4
source share
4 answers

This is an error report that I filed using the Apple Developer Error Reporting Tool. This is apparently one of the big problems causing a memory leak in my case.

: NSURL NSData dataWithContentsOfURL: createCanonicalURL().

, , loadView: viewDidLoad: .:

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:" .

: .

: .

: URL-, URL . URL-, "http:/blah/blah.png", . , , :

  • iPad 4.3 Simulator
  • iPad 2 iOS 4.3.1

: :

STACK TRACE START

   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

+2

. , , , javascript. ?

+1

[webView loadHTMLString: @"" baseURL: nil];

webview. 4.2.1, PDF UIWebView, .

+1

, UIWebView - (General-Block56 ..) iPad, iPad2, iPhone. , : Nib 'viewDidLoad'. - "loadView":

- (void)loadView 
{ 
    self.activityView = [[[UIActivityIndicatorView alloc]    initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    self.webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [self.webView addSubview: self.activityView];
    self.webView.scalesPageToFit = YES;
    self.view = self.webView;
    [self addGestures];
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
      self.webView.delegate = self;
      [self.webView loadRequest:[self urlRequest]];
      [super viewWillAppear:animated];

}

(16 ) . - . .

+1

All Articles