Bug 53177 - WebView leaks memory when its HTML source string is changed
Summary: WebView leaks memory when its HTML source string is changed
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.5
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
Depends on:
Reported: 2017-03-09 03:19 UTC by Richard Jiang
Modified: 2017-08-11 17:31 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Richard Jiang 2017-03-09 03:19:30 UTC

I did a test on Xamarin Studio 6.12, with our app, targeting on a Samsung S4 device with Android 4.4.1.

The test created a Webview object:

		... new WebView {
				VerticalOptions = LayoutOptions.Fill,
				WidthRequest = Size,
				HeightRequest = Size,
				Source = new HtmlWebViewSource { Html = htmString }

then changed the Html string 720 times.

Then I found:

1) In time frame: 20:57pm to 21:45pm, in 48 minutes, app memory usage climbed from 185 to 205. That's 20mb increase. Average increase is 417kb/minute,  27kb per html-src-change.

2) then app was idle afterwards and memory usage stayed.

So, the test shows changing webview html source causes average 27kb memory leak.


Richard Jiang
Comment 1 Jon Douglas [MSFT] 2017-07-07 21:12:02 UTC
Moving this bug to Xamarin.Forms as it seems more related to the implementation of WebView.
Comment 2 Jimmy [MSFT] 2017-07-11 17:31:49 UTC
Hi Richard,

Are you still seeing this even with the latest 2.3.5 pre-release? Can you share a copy of the profiling session you did so I can compare with a profiling run here? When providing the requested information, please set the report's status back to NEW otherwise we may close this issue after 30 days of no response. Thanks!
Comment 3 Jimmy [MSFT] 2017-08-11 17:31:23 UTC
Because we have not received a reply to our request for more information, we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information so we can continue looking into this. Thanks!