且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在高度并发代码中提高.NET 4.0的垃圾回收器性能?

更新时间:2023-10-19 16:23:40

如果由于分配太多对象/ GC编译,GC运行太频繁,请尝试分配更少的对象: )

If GC is running too often due to too many objects being allocated/GC-ed, try to allocate fewer of them :)

根据你的场景 - 尝试重用现有对象,创建一个对象池,使用较轻的对象,不要放那么大的内存压力

Depending on you scenario - try to reuse existing objects, create an object pool, use "lighter" objects that do not put so much memory pressure (or larger to reduce the number of objects allocated).

不要尝试通过调用GC.Collect显式地管理GC,它很少支付( Rico Mariani这样说

Do not try to "manage GC" by calling GC.Collect explicitly, it very rarely pays off (Rico Mariani says so)

http://blogs.msdn.com/ ricom / archive / 2003/12/02 / 40780.aspx