Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView leaks, JS Garbage Collector & WebCore VMs

Tags:

I've been building a browser feature for an app which obviously works with UIWebView. I've been seeing memory jump up when the browser opens which makes sense, however i'm seeing some troubling results during a leaks profile:

Leaks profiling

The VM: JS garbage collector and VM: WebCore purgeable data just keep climbing the more I browse. Whats even worse is that when the browser is deallocated and it's web view released, these objects are still there, taking up upwards of 6 MB of memory.

I'm not sure what if i'm not handling UIWebView correctly but there seems to be an issue with this memory being held on to after the UIWebView is deallocated.

I perform some cleanup prior to the browser being deallocated as detalled in this post http://www.codercowboy.com/code-uiwebview-memory-leak-prevention/ but this doesnt seem to be making any difference.

Has anyone had this issue? Any insight would be awesome. I've seen a few questions already related to UIWebView memory issues however they don't specifically detail the results of a profile.

like image 468
Aron Avatar asked Nov 27 '13 05:11

Aron


1 Answers

I'm unsure if I would immediately consider this a problem. Those VMs only start when you add a web view to your view hierarchy and load a request with it.

It may just be the OS that keeps those resources alive in case they will be used again.

I tried to replicate your code that cleans up the data and had drops of 50%.

The JS Garbage collector was always at around 3MB minimum, but had maximums of 8MB The WebCore purgeable data was always at around 700KB

You may also consider that this may be related to bad JavaScript that continues to live because of leaks in the JavaScript code.

like image 186
David Carvalho Avatar answered Oct 30 '22 09:10

David Carvalho