Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Memory Leak

After running our stress testing on our ASP.NET application access to internal web services, our mid-tier server (where we host ASMX .NET 3.5 web services) showed close to 1GB of memory consumption.

Upon the review of memory dump from mid-tier server, I have found over 1000 objects of Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer referenced by Web Services runtime itself.

Is this anything related to how our custom objects are getting serialized/deserialized in the web services layer? Could anyone shed more light on this?

When I did !gcroot on some of these 1000 objects, I got the following trace: (Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Storage.ConfigurationChangeFileWatcher)-> 1c4bb450(System.Threading.Thread)-> 18236aa0(System.Runtime.Remoting.Contexts.Context)-> 18236914(System.AppDomain)-> 10409dc4(System.ResolveEventHandler)-> 10409494(System.Web.Compilation.BuildManager)-> 10409f30(System.Web.Compilation.MemoryBuildResultCache)-> 103d115c(System.Web.Caching.CacheMultiple)-> 103d1174(System.Object[])-> 103d2034(System.Web.Caching.CacheSingle)-> 103d2080(System.Collections.Hashtable)-> 1c24b97c(System.Collections.Hashtable+bucket[])-> 1c24b934(System.Web.Caching.CacheEntry)-> 18363994(System.Web.Services.Protocols.SoapServerType)-> 183639c4(System.Collections.Hashtable)-> 1c24aa5c(System.Collections.Hashtable+bucket[])-> 1c24a458(System.Web.Services.Protocols.SoapServerMethod)-> 1c248ae4(Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer26)

(Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Storage.ConfigurationChangeFileWatcher)-> 1c5ac4b0(System.Threading.Thread)-> 1c52b5f0(System.Runtime.Remoting.Contexts.Context)-> 1c52b464(System.AppDomain)-> 18823880(System.ResolveEventHandler)-> 18822f50(System.Web.Compilation.BuildManager)-> 188239e0(System.Web.Compilation.MemoryBuildResultCache)-> 144631fc(System.Web.Caching.CacheMultiple)-> 14463214(System.Object[])-> 14465088(System.Web.Caching.CacheSingle)-> 144650d4(System.Collections.Hashtable)-> 1446510c(System.Collections.Hashtable+bucket[])-> 1c5a580c(System.Web.Caching.CacheEntry)-> 109e6e34(System.Web.Services.Protocols.SoapServerType)-> 109e6e64(System.Collections.Hashtable)-> 1c5a4fcc(System.Collections.Hashtable+bucket[])-> 1c5a4a54(System.Web.Services.Protocols.SoapServerMethod)-> 1c5a44f4(Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer28)

(Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Storage.ConfigurationChangeFileWatcher)-> 108b38f0(System.Threading.Thread)-> 1c1155ec(System.Runtime.Remoting.Contexts.Context)-> 1c115460(System.AppDomain)-> 1030d348(System.ResolveEventHandler)-> 1030ca18(System.Web.Compilation.BuildManager)-> 1030d4a0(System.Web.Compilation.MemoryBuildResultCache)-> 102d7ae4(System.Web.Caching.CacheMultiple)-> 102d7afc(System.Object[])-> 102d7b1c(System.Web.Caching.CacheSingle)-> 102d7b68(System.Collections.Hashtable)-> 102d7bac(System.Collections.Hashtable+bucket[])-> 181ee124(System.Web.Caching.CacheEntry)-> 10350eac(System.Web.Services.Protocols.SoapServerType)-> 10350edc(System.Collections.Hashtable)-> 181ed260(System.Collections.Hashtable+bucket[])-> 181ed148(System.Web.Services.Protocols.SoapServerMethod)-> 181eb708(Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer61)

Thanks BK

like image 850
BK Krish Avatar asked Nov 05 '22 10:11

BK Krish


2 Answers

You might want to try instrumenting your code with ANTS Memory Profiler from Red Gate.

like image 53
Vitor Py Avatar answered Nov 15 '22 10:11

Vitor Py


I would strongly recommend us of the simply named .Net Memory Profiler from http://memprofiler.com/download.aspx.

You can use the full version for 14 days for free.

I have found it useful for this type of problem solving. It will show you the reference tree. Making fixing these type of problems really easy.

like image 21
morechilli Avatar answered Nov 15 '22 11:11

morechilli