asifshaon / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

Severe memory leaks impacting performance and scalability of 2LO client applications #188

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Semaphore limit = new Semaphore(100, 100);
ThreadPool.SetMaxThreads(102, 102);
ThreadPool.SetMinThreads(102, 102);
for (int i = 0; i < 15000; ++i)
{
    limit.WaitOne();
#if false
    var gauth = new Google.Apis.Authentication.OAuth2LeggedAuthenticator(consumerKey, consumerSecret, "username", "example.org");
    var svc = new Google.Apis.Calendar.v3.CalendarService(gauth);
    svc.CalendarList.List().FetchAsync(req => { try { req.GetResult(); } finally { limit.Release(); } });
#else
    var req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.google.com");
    req.BeginGetResponse((iar) => { try { var req_ = (System.Net.HttpWebRequest)iar.AsyncState; req_.EndGetResponse(iar).Close(); } finally { limit.Release(); } }, (object)req);
#endif
}
Console.WriteLine("Press a key . . .");
Console.ReadKey();

What is the expected output? What do you see instead?
See attached memory usage graphs attained via ProcessExplorer.

One run is using a real domain account to request information for. Memory is 
leaked and never reclaimed.

The other run is using a non-existent user to test the WebException case. Much 
more memory is leaked than the non-exceptional case and is never reclaimed.

Switch the `#if true` to `#if false` to see that the private memory baseline is 
around 120MB for a max of 100 threads working on requesting the www.google.com 
homepage.

What version of the product are you using? On what operating system?
Google.Apis.Calendar.v3.dll, 1.1.4344.23403
Windows 7 Enterprise x64, .NET 3.5SP1

Please provide any additional information below.
I need to allocate this many CalendarService instances because I'm using 2LO 
and have to vary the username I request information for. I have on the order of 
10,000s of users in my domain to make requests on behalf of.

Original issue reported on code.google.com by james.jdunne@gmail.com on 20 Feb 2012 at 9:36

Attachments:

GoogleCodeExporter commented 9 years ago
Likely caused by undisposed streams (See Issue 189)

Original comment by asky...@google.com on 25 Apr 2012 at 7:16