繁体   English   中英

TimerCallback.PerformTimerCallback内存分配

[英]TimerCallback.PerformTimerCallback memory allocation

我有WCF服务,正在分析其内存分配。
我看到每个请求分配的内存的36%是通过TimerCallBack.PerformTimerCallback分配的,而后者又调用了以下内容:
ExecutionContext.CreateCopy
ExecutionContext.Run
所有这些分配甚至都没有经过我的代码,仅分配了诸如Hahtable.bucket和ExecutionContextRunData之类的通用对象。

出于应用原因,我在服务中使用了Timer,我为每个请求创建了一个带有简单回调的请求,该回调更新了布尔值,然后立即将其处理。 可能相关吗?

这是相关的分配图:

<root> :   41 MB    (100.00%)
 System.Threading._TimerCallback::PerformTimerCallback static void (Object):   41 MB    (100.00%)
  System.Threading.ExecutionContext::CreateCopy System.Threading.ExecutionContext ():   30 MB    (73.96%)
  System.Threading.ExecutionContext::Run static void (System.Threading.ExecutionContext System.Threading.ContextCallback Object):   11 MB    (26.04%)
   System.Threading.ExecutionContext::RunInternal static void (System.Threading.ExecutionContext System.Threading.ContextCallback Object):  7.8 MB    (19.18%)
   System.Data.ProviderBase.DbConnectionFactory::PruneConnectionPoolGroups void (Object):  2.6 MB    (6.42%)
   System.Data.ProviderBase.DbConnectionPool::CleanupCallback void (Object):  183 kB    (0.44%)
    System.Data.ProviderBase.DbConnectionPoolGroup::ClearInternal bool (bool):  1.2 MB    (3.06%)
    System.Collections.Generic.Dictionary<T,U>::.ctor void (int32):  840 kB    (2.02%)
    System.Threading.ThreadPool::QueueUserWorkItem static bool (System.Threading.WaitCallback):  183 kB    (0.44%)
     System.Collections.Generic.Dictionary<T,U>::.ctor void (int32 <UNKNOWN>):  840 kB    (2.02%)
     System.Collections.Specialized.HybridDictionary::Add void (Object Object):  305 kB    (0.73%)
     System.Collections.Specialized.HybridDictionary::GetEnumerator void ():  255 kB    (0.61%)
     System.Collections.Specialized.ListDictionary::Add void (Object Object):  255 kB    (0.61%)
     System.Collections.Specialized.ListDictionary.NodeEnumerator::get_Current Object ():  204 kB    (0.49%)
     System.Threading.ThreadPool::QueueUserWorkItemHelper static bool (System.Threading.WaitCallback Object System.Threading.StackCrawlMark& bool):  183 kB    (0.44%)
      System.Collections.Generic.Dictionary<T,U>::Initialize void (int32):  840 kB    (2.02%)
      System.Threading._ThreadPoolWaitCallback::.ctor void (System.Threading.WaitCallback Object bool System.Threading.StackCrawlMark&):  135 kB    (0.32%)
       System.Threading.ExecutionContext::Capture static System.Threading.ExecutionContext (System.Threading.StackCrawlMark&):  135 kB    (0.32%)
        System.Runtime.Remoting.Messaging.LogicalCallContext::Clone Object ():   26 MB    (63.75%)
         System.Collections.Hashtable::.ctor void (int32 float32):   15 MB    (36.34%)
         System.Collections.Hashtable::GetEnumerator System.Collections.IDictionaryEnumerator ():  2.9 MB    (7.07%)
          System.Collections.Hashtable.bucket [] :   15 MB    (36.34%)
          System.Threading.ExecutionContext.ExecutionContextRunData :  7.8 MB    (19.18%)
          System.Collections.Hashtable :  4.5 MB    (11.10%)
          System.Threading.ExecutionContext :  4.3 MB    (10.53%)
          System.Runtime.Remoting.Messaging.LogicalCallContext :  3.8 MB    (9.24%)
          System.Collections.Hashtable.HashtableEnumerator :  2.9 MB    (7.07%)
          System.Collections.Generic.Dictionary<T,U>.Entry [] :  611 kB    (1.47%)
          System.Collections.Generic.Dictionary<T,U> :  560 kB    (1.34%)
          System.Collections.Specialized.ListDictionary :  305 kB    (0.73%)
          System.Collections.Specialized.ListDictionary.NodeEnumerator :  255 kB    (0.61%)
          System.Collections.Specialized.ListDictionary.DictionaryNode :  255 kB    (0.61%)
          System.Collections.Specialized.HybridDictionary :  255 kB    (0.61%)
          System.Int32 [] :  229 kB    (0.55%)
          System.Collections.DictionaryEntry :  204 kB    (0.49%)
          System.Threading._ThreadPoolWaitCallback :   48 kB    (0.12%)
           <bottom> :   41 MB    (100.00%)

所有这些分配来自哪里? 这正常吗?
有办法降低其中的一些吗?

为了完整起见,问题在于有人将MaxBufferSize和MaxBufferPoolSize值更改为以前值的1000倍。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM