I have Samsung Galaxy S4 (Android 5.0.1). I tested 2 applications with a WebView.
In one of them a geographical map is used with marks and lines (paths). After 10-20 shifts and zooms it crushed with OutOfMemory.
In the second a site of a company is used integrated in Cordova. After 20-60 page loadings it also crushes with OutOfMemory.
When I see a memory allocation, it acts like a saw: after an increase up to some limit it frees, then again increases. After 2-4 peaks it crushes.
On some other devices these crushes are not reproduced. The same is in replies at PlayMarket.
I read many articles including http://www.dwmkerr.com/fixing-memory-leaks-in-angularjs-applications/. An application uses Angular JS. When I tested it in Chrome and Firefox developer's console I saw that after peaks up to 12 Mb a garbage collector in a browser started.
I have these questions:
Does a WebView have it's own garbage collector (I think, Javascript GC)?
If a WebView is just a View, why it is not destroyed, but a whole application crushes?
How Android GC can affect WebView (maybe Chromium GC) and how WebView can tell Android GC to free a memory?
As nobody answered, I reply.
I connected devices to Chrome, entered "chrome://inspect" and watched a spreading of memory (including JS Heap) on time. On Samsung devices a memory constantly increased after events in WebView. On HTC (Android 2.3.3) it increased, then again cleaned by GC (every second). On Samsung Galaxy S4 it raised from 20 Mb up to 30 and then crushed. On Galaxy Tab A it started from 7 Mb and so didn't crush.
A Chrome developer console also showed a work of GC in WebView. Sometimes it launched Major GC, sometimes Minor GC. I think, that was a Javascript GC inside WebView, as it had not led to cleaning memory in Java.
1) Every implementation of a browser on every platform has it's own GC (including Javascript GC).
2) WebView is a very complex View, so it may easily crush an application.
3) I think, Android may ask WebView to free some memory, it launches it's GC. But depending on the platform it can decrease a used memory by WebView (on HTC 2.3.3) or leave it intact. So even if a GC was run in WebView, it often won't free memory in the application.