NET垃圾收集不那么频繁

NET垃圾收集不那么频繁

本文介绍了如何使.NET垃圾收集不那么频繁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有procesess大量的小物件,比如一个应用程序2000消息每秒。一个消息是大约100字节,也许更少。该应用程序跑了6个半小时的负载下,在这段时间它有264 NBSP; 416 0 根集合,166  699 1 根和69  608 2 根。这是每秒11.6,7.3和3的集合分别

I have an application that procesess large number of small objects, e.g. 2000 messages per second. One message is roughly 100 bytes, maybe less. The application ran for 6 and a half hours under load and during that time it had 264 416 0 gen collections,166 699 1 gen and 69 608 2 gen. This is 11.6, 7.3 and 3 collections per second respectively.

现在的问题是如何使垃圾收集不那么频繁?

The question is how to make garbage collection less frequent?

UPD:应用程序是一个服务器从WCF接收消息,pughing他们虽几经处理模块,并将其保存到数据库中。

UPD:Application is a server receiving messages from WCF, pughing them though several processing modules and saving them to database.

我是根据IM pression的GC要适应一段时间之后增加发电规模,但这是obviousely并非如此。

I was under impression that GC should adapt and increase generation size after some time but this is obviousely not the case.

UPD 2 :在建议leppie's回答服务器模式 GC确实使得10倍以下的集合。此外,它出现时(如里氏描述的那样),频繁的集合是不是一件坏事。

UPD 2: as suggested in leppie's answer GC in server mode indeed makes 10 times less collections. Also it appears (as Richter describes it) that frequent collections are not a bad thing.

推荐答案

您将获得约10倍的GC的,如果你启用 gcServer =真正的在应用程序。配置。但注意,这并不能提高性能,你将有可能已经在你的应用程序增加的延迟,如果它是一个桌面应用程序。

You will get about 10 times less GC's if you enable gcServer="true" in the app.config. But do note, this does not improve performance, and you will have likely have increased latency in your application if it is a desktop application.

下面是App.config中设置:

Here is app.config setting:

<runtime>
  <gcServer enabled="true"/>
</runtime>

这篇关于如何使.NET垃圾收集不那么频繁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 11:16