.NET 0代堆大小 [英] .NET generation 0 heap size

查看:577
本文介绍了.NET 0代堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能设置的第0代堆中的最小尺寸在.NET?

Is it possible to set a minimal size of a generation 0 heap in .NET?

我有如下因素sistuation。我有一个功能,分配MB 1KB约为20-30对象,做了他们,并终止,使所有分配的对象是GC-ED。现在,在性能监视器,我可以看到,0代堆大小是5-6 MB,这是不够的,接受所有的20-30 MB,我需要的对象。当我开始分配,在某些时候gen0 GC开始运行,并且因为需要的所有对象,它促进他们到第一代。下一次GC开始运行,这些对象获得提升的第二代。所以最后我的周围物体的15MB结束在第二代堆。这些是,通过我的逻辑,即不应以任何方式结束在根2堆临时对象。我相信这个问题是在gen0堆大小的尺寸。但我不知道。我知道在爪哇有可能设置代堆的最小尺寸。是否有.NET这样的方式?

I have a folowing sistuation. I have a function that allocates around 20-30 MB of 1KB objects, does something with them, and terminates, leaving all the allocated objects to be GC-ed. Now, in Performance Monitor, I can see that generation 0 heap size is 5-6 MB, which is not enough to accept all the 20-30 MB of objects that I need. When I start allocating, at some point gen0 GC starts running, and since all the objects are needed it promotes them to a gen1. Next time GC starts running, these objects get promoted in gen2. So finally around 15MB of my objects end up in the gen2 heap. These are, by my logic, temporary objects that should in no way end up in the gen2 heap. I belive the problem is in the size of the gen0 heap size. But I'm not sure. I know that in Java there is a possibility to set a minimal size of the generational heaps. Is there such a way in .NET?

推荐答案

在不同代的大小是一个实现细节,我不知道有任何的方式来调整它的.NET应用程序。如果我没记错的正确代0和1股单个段,这是16 MB在Win32中,所以如果你创建了一大堆的对象,其中的一些将被提升到更高的一代,如果他们仍然引用(就像您所描述)。

The size of the different generations is an implementation details, and I am not aware of any ways to tune it for .NET applications. If my memory serves me correctly generation 0 and 1 shares a single segment, which is 16 MB in Win32, so if you do create a whole lot of objects, some of these will be promoted to higher generations if they are still referenced (just as you describe).

我想后面的限制0代的尺寸的想法是,以确保一个G0收集便宜。如果第0代可能增长到任何尺寸,整体性能很可能会受到影响。

I guess the idea behind limiting the size of generation 0 is to make sure a g0 collection is cheap. If generation 0 could grow to any size, your overall performance would most likely suffer.

编辑:我相信杰弗里Ritchers本书有这方面的一些细节,所以你可能要检查了这一点。

I believe Jeffrey Ritchers book has some details on this, so you may want to check that out.

EDIT2:Ricther状态(第502-507)那一代0的初步预算为256 KB和1代的初步预算为2 MB。然而,这是不产生的大小。预算的调整按照需要和将增长,并根据应用程序的内存使用收缩。

Ricther states (p. 502-507) that generation 0's initial budget is 256 KB and generation 1's initial budget is 2 MB. However, that is not the size of the generation. The budgets are adjusted as needed and will grow and shrink according to the application's memory usage.

乔·达菲的专业的.NET Framework 2.0然而,指出ephermal代(即代0和1)共享一个段,这就通常16 MB(第117页)。只有第2代是允许根据需要成长(我假设LOH允许根据需要也增长,但说不清楚我的文字)。

Joe Duffy's Professional .NET Framework 2.0 however, states that the ephermal generations (i.e. gen 0 and 1) shares a single segment, which is usally 16 MB (p. 117). Only generation 2 is allow to grow as needed (I assume LOH is allowed to grow as needed as well, but that is not clear to me from the text).

这篇关于.NET 0代堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆