4

WKWebview leaks memory on iOS 8.4. It can be detected using Instruments (Leaks). When we check the Stack Trace, it points towards the initialisation of WKWebView.

webView = [[WKWebView alloc] initWithFrame:_displayView.frame];

If we drill down, we can figure out that UIWebSelectionAssistant & _UIKeyboardTextSelectionGestureController are allocated but never released.

Since these are called by WKWebView internally, I don't know how to release them. Although I am using ARC, but still I have written these in dealloc method:

[webView stopLoading];
webView.navigationDelegate = nil;
[webView removeFromSuperview];
webView = nil;

However, still I can't avoid leaks. More details can be found in the screenshot attached. Link to leaks screenshot

Thanks!

  • You can find an answer to your question here http://stackoverflow.com/a/35319796/2208785 – pJes2 Mar 17 '16 at 11:29
  • Thanks for your reply. Mentioned solution does not work! The problem is on iOS 8.4 and not on iOS9. Sorry for the incorrect OS version number. Just for your information, the webview content is not text rather it is an image! – Chaitanya Khurana Mar 21 '16 at 08:05
  • The solution posted in that link does not work regardless. This seems to be an issue with wkWebView itself. For reference: https://forums.developer.apple.com/thread/22795 and https://forums.developer.apple.com/thread/21956 – Vemonus Aug 17 '16 at 18:35

0 Answers0