iOS 9 Memory Leaks in UIWebView

Hello,


we have the problem that while using our WebApp the used memory of our WebApp grows until the App is unusable.

As far as I can see its a bug in the UIWebView, there is no Problem in Safari.


This problem only occurs in iOS 9. Are there any known bugs or memory leasks in the current UIWebView? Or any other Ideas?

We would badly need to solve that!


If you need more Information, just ask. Sadly I was not able to build a sample project yet. Perhaps I will get a sample project working in the next two days.



Thanks in advanced

I am having exactly the same problem in iOS 9.1 with a UIWebView-based app. The app can be used indefinitely in iOS 8 without a performance issue, but after about 20 minutes (2-3 page loads per minute) it crawls and the scrolling gets really jerky in iOS 9.1.


I'm trying to figure out what is leaking, but I have a hunch it's in the UIWebView control itself.

MAtthew! I have the same problem... some solution?

Hi...I have the same problem...some solution?

We've got the same issue. I've attached Instruments to it on our OSX dev machine and found that the number of Allocated Heap Objects will climb until it hits a magic 65,535 mark, at which point it starts paging to disk causing the UI to appear to lock up and go slow, when the number of objects will drop down to around 62,000. Unfortunately, scrolling will cause another 2,000 heap objects to be created so there's more lagging as the user starts to scroll. The trigger happens to us after 50 - 75 page loads.

We've tested on multiple devices anything from an old iPad2 to a newish iPad Air 2 and they'll be fine on iOS5 - 8, but as soon as any version of iOS9 is on the device, it starts leaking objects and crawling.

The only workaround we've found is to get our users to kill the app and launch it again, which isn't a great experience.

We just tried out a workaround of destroying the UIWebView and recreating it after every 20 requests, and the problem has gone away for us

@EionRobb what do you mean by destroying the UIWebView and recreating it after every 20 requests?


My UIWebView got freed when I pop to home view controller, but leak instrument still report leak.

I have the same problem,when I pop to home view controller,leak:

  • [UIWebSelectionAssistant addNonEditableForceTextSelectionGestureRecognizersToView:]
  • [UIKeyboardTextSelectionGestureController init:]

some solution?

Hi Eion,


Can you tell us please how you managed to destroy the webview? My app was originally a cordova app and I don't know Objective C so very new to it.


Thanks in advance

The solution posted here worked for me.

iOS 9 Memory Leaks in UIWebView
 
 
Q