Problem:
WebView not releasing memory after loading images.
The memory does seem to get released if all WebView instances are destroyed for few seconds. We removed from XAML tree and all references in code cleared. (We checked in debugger that all instances were released at that point.)
This solution is problematic since the web view must be dead for a while for the memory clearing to kick in and is unacceptable for our use case.
How to reproduce:
Make either a UWP C# app or a C++ UWP app -> add a WebView -> load large images with randomized URLs -> Memory keeps growing.
We have only one active WebView and we load a large image in it multiple times one after another. (We randomise part of the image url to simulate different ad loads.)
The memory keeps growing as if the images never get released. What we tried:
- Clearing cache with WebView.ClearTemporaryWebDataAsync() but it doesnt do anything.
- Manually triggering GC.
Notes:
- We initialise webview using this "WebView(WebViewExecutionMode.SeparateThread)". (other execution modes don't seem to help).
- We do not use a WebViewBrush.