0
votes

i am getting following memory leaks for webview

    initWebUILocalStorageSupport
    MobileQuickLookLibrary()

and here is my code, i dont know what i am missing.

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0f];
[theRequest setHTTPMethod:@"POST"];

NSData *data = [self GenerateData];
if (data) {
    [theRequest setHTTPBody:data];
}
[webView loadRequest:theRequest];

i hope my question is clear.thanks

EDIT: adding code for GenerateData

NSArray * results = [self.managedObjectContext executeFetchRequest:request error:&error];
if (!error) {
    for (Items *item in results) {

    }
    NSString *theBodyString = [[CJSONSerializer serializer] serializeDictionary:theRequestDictionary];
    theBodyData = [theBodyString dataUsingEncoding:NSUTF8StringEncoding];
    }
return theBodyData;
3
Show the code for your GenerateData method. (Aside: method names in Cocoa generally should start with a lower-case letter.) - Shaggy Frog

3 Answers

0
votes

Are you testing the simulator or on a real device?

The simulator is known to have some memory leaks that are not present in real devices.

0
votes

Try:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
  [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
}

From http://blog.techno-barje.fr/post/2010/10/04/UIWebView-secrets-part1-memory-leaks-on-xmlhttprequest

0
votes

I got a

received memory warning, level 1

and then the application crashed with the huge text size in the web view. This article helped me, solving the leak issue. Very easy and straightforward to use.