简体   繁体   中英

How to get the heap memory allocated to each generation (Gen0,Gen1,Gen2)?

As stated in CLR via C#, "When CLR initializes, it selects a budget size for each generation.". It assumes 256KB for Gen0, 2MB for Gen1, 10MB for Gen2.(not sure if this includes Large Object Heap)

This budget must, ofcourse, be getting increased as more objects are created and as the size of the heap increases.

I know about GC.GetTotalMemory() method which returns the total memory that has been consumed, but it gives no information about per generation consumption.

Is there a way to get the heap size allocated to each generation?

IF you really want to dig deeper into .NET memory management then I recommend checking these links out:

The above links provide lots of insight AND a CLR memory profiler written by MS which comes with full source code...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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