Bug 40673 - WebService memory leak
Summary: WebService memory leak
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web.Services ()
Version: 4.4.0 (C7)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-04-25 15:53 UTC by Tadej
Modified: 2016-12-16 13:19 UTC (History)
2 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 for Bug 40673 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Tadej 2016-04-25 15:53:03 UTC

I'm using a self hosted HTTP JSON Webservice:

Uri serviceAddress = new Uri(HttpServiceUri);
mHttpServiceHost = new WebServiceHost(WebService, serviceAddress);
WebHttpBehavior beh = new WebHttpBehavior
 FaultExceptionEnabled = false,
 HelpEnabled = false
mHttpServiceHost.AddServiceEndpoint(typeof(IWebService), CMWCFBindings.GetWebBinding(), serviceAddress).Behaviors.Add(beh);

Using the web binding:

WebHttpBinding httpBind = new WebHttpBinding();
httpBind.MaxBufferSize = 204003200;
httpBind.MaxReceivedMessageSize = 204003200;
httpBind.AllowCookies = false;
httpBind.CrossDomainScriptAccessEnabled = true;

XmlDictionaryReaderQuotas rq = new XmlDictionaryReaderQuotas();
rq.MaxDepth = 2147483647;
rq.MaxArrayLength = 2147483647;
rq.MaxBytesPerRead = 2147483647;
rq.MaxStringContentLength = 2147483647;
rq.MaxNameTableCharCount = 2147483647;
httpBind.ReaderQuotas = rq;
return httpBind;

Using operation contracts like:

[WebInvoke(Method = "POST",
 RequestFormat = WebMessageFormat.Json,
 UriTemplate = "GetPanel")]
Stream GetPanel(GetPanelParams path);


[WebGet(UriTemplate = "GetClientData")]
Stream GetClientData();

Operation contracts convert data into JSON string and return memory stream: 

JavaScriptSerializer jss = new JavaScriptSerializer();
jss.MaxJsonLength = 100000000;
return new MemoryStream(Encoding.UTF8.GetBytes(jss.Serialize(obj)));

In Mono version the WebService specified above works perfectly. Recently I tried upgrading to Mono where I'm noticing a memory leak with each service call. The memory is rising quickly until the application crashes.

Operating system: Arch Linux
Hardware: Raspberry Pi 2
Comment 1 Alex 2016-12-16 08:38:22 UTC
I think a root of this problem is the same with one described in:
Comment 2 Tadej 2016-12-16 13:19:35 UTC
Yes Alex, looks like the same problem. I'm still stuck on version