【问题标题】:.NET Memory Leak.NET 内存泄漏
【发布时间】:2011-03-22 06:05:39
【问题描述】:

在对访问内部 Web 服务的 ASP.NET 应用程序进行压力测试后,我们的中间层服务器(我们托管 ASMX .NET 3.5 Web 服务的地方)显示出接近 1GB 的内存消耗。

通过查看中间层服务器的内存转储,我发现 Web 服务运行时本身引用了超过 1000 个 Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer 对象。

这是否与我们的自定义对象在 Web 服务层中如何序列化/反序列化有关?任何人都可以更清楚地说明这一点吗?

当我对这 1000 个对象中的一些对象执行 !gcroot 时,我得到了以下跟踪: (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)

谢谢 BK

【问题讨论】:

  • 我强烈建议迁移到 WCF。
  • 我愿意。这是现有代码,我们最近更新到 ASP.NET 3.5

标签: .net asp.net web-services memory memory-leaks


【解决方案1】:

我强烈推荐我们使用来自http://memprofiler.com/download.aspx 的简单命名的.Net Memory Profiler

您可以免费使用完整版 14 天。

我发现它对解决这类问题很有用。它将显示参考树。让解决这些类型的问题变得非常容易。

【讨论】:

    【解决方案2】:

    您可能想尝试使用 Red Gate 的 ANTS Memory Profiler 检测您的代码。

    【讨论】:

      猜你喜欢
      • 2012-02-19
      • 1970-01-01
      • 2022-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      相关资源
      最近更新 更多