In my app I've got a page with a carousel of ContentViews. Each ContentView is essentially a container for a WebView, in which I have html with text, images, and social and video embeds.
I'm loading content into my WebView on demand, triggered by carousel navigation, so that the view 2 ahead of the one I'm currently on will load when you advance the carousel to the next screen.
Likewise, I'm attempting to clear out the content in the same manner. So, the WebView that is 2 behind the one you are currently on will clear out its contents, in an effort to keep memory management under control.
My problem is, the content in my WebViews doesn't ever seem to be getting released. While debugging on a physical device after scrolling through a few of these screens, I will begin to get memory warnings in my debugger, and eventually the app will crash.
The way I'm trying to free up the memory in my WebViews is through a Dispose method in my WebView that gets called once the WebView is offscreen, like so:
public void Dispose()
{
this.Source = "";
UnapplyBindings();
}
Unfortunately, this doesn't seem to be doing the trick and the memory from the WebViews contents isn't getting released, even though I can see the source is blank. How can I free up the memory consumed by my WebViews?