I have a Webview where I try to post huge amount of data say around 20 MB which includes images. I have collected everything into a string and passed that particular string to webview. The problem arises when the string size increases. It works fine if the size of the string is less.
I did check by debugging, that the control reaches the WebViewDidFinishLoading delegate method. The fully loaded string gets uploaded , but the application gets crashed within couple of seconds. What might be the reason? Please help me out! I have been banging ma head.
Its possible that you are using up too much memory. iOS kills such apps. Apart from loading such a huge HTML, UIWebView itself has memory issues. Its been accused of taking too much memory as it caches data (images etc.)
Maybe emptying the cache could help. In didFinishLaunchingWithOptions try this -
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
Also when you receive memory warning do this -
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
You are just purging cache to free up memory.
If this too is not working then i suggest you figure out ways to split your HTML into multiple pages or some other way to present data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With