Crash when loading large html on UIWebView *** error: can't allocate region securely


We have a webview that loads email content, on some cases we get a very large email (1+ mb), when we attempt to load one of these mails from a string in memory the app crashes, no stack trace or other information except for this error

2016-01-25 19:34:27.079 testApp [19436:1092350] critical: at <0xffffffff>
testApp(19436,0x96c31d4) malloc: *** mach_vm_map(size=8388608) failed (error code=3)
*** error: can't allocate region securely
*** set a breakpoint in malloc_error_break to debug
2016-01-25 19:34:27.080 testApp[19436:1092350] error: Could not allocate 896 bytes

The way i'm loading the web view with the html is by simply retrieving the content from a stream and then loading it like this

webView.LoadHtmlString(htmlContent, null);

After debugging i can see that the calculated content height of the web view after loading the string is about 500,000, i think the app is running out of memory maybe?

I suspect the content size causes the webview to use more memory than available and crashes the app, since it requires lots of memory to render the 1+ mb html content but i don't have a way to determine how much memory is being used or if this is indeed the problem.

Anyone else seeing this issue? i tried looking for size limits on a web view but can't find anything related.

Partially loading the content may not be an option so i would like to know if someone else has gone through this and what was the optimal solution.

Any help would be really appreciated.



Sign In or Register to comment.