.NET generation 0 heap size

后端 未结 7 1837
礼貌的吻别
礼貌的吻别 2021-01-01 21:21

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

I have a folowing sistuation. I have a function that allocates around 20-30 MB of 1KB objects, d

相关标签:
7条回答
  • 2021-01-01 21:46

    At first generation0 may increase and decrease but these are in future. when process runs the initialized managed heap has fixed size in generation0 256 KB (which meant Richter) because modern computers have 256 and more memory for 2-nd level CPU's cash. Second. Andrew, you are right. When some object is so large it goes to gen2 at once. I can suppose you wanted to decrease gen0 size to provoke more frequently called GC to clear unused space and keep your app lighter. I have same problem in a SilverLight web site and search a solution. I think what if code creates much object which have roots and when gen0 is full CLR calls GC which move them to gen1, and then when objects grow more move them to gen2. Let's say all 3 generation are nearly full. Then for example GC called. What it will do. Just clear generation0 ? How with 1-st and 2-nd ones. I think sollution to keep memory light is the following. First create small and much objects instead of large in size and less in count. Second objects internal referencing must be one way oriented and not chaotic referencing to each other. Static objects which are not created dynamically for example according to comming records from database, need to keep in global variables and not create again when code cals them.

    0 讨论(0)
提交回复
热议问题