liveBook · Manning

Generation 0

As explained in .NET in Action, Second Edition

Generation 0 is the youngest .NET garbage-collection generation, containing newly allocated objects and collected most frequently.

Generation 0 (Gen0) is the youngest .NET garbage-collection generation. Its collections are the fastest and most frequent, aiming to avoid long pauses or compaction. Memory that is still referenced cannot be freed and survives into Gen1, which is collected less often. section 10.3.4

Use collection counts alongside pause time and allocation totals when investigating memory use. Avoid forcing collections in an application: doing so is useful for benchmarks but rarely improves application performance. section 10.3.4

Table 10.2 GCStats table from PerfView from the Newtonsoft benchmark method profile (view table figure)

Gen

Count

Total pause

Total alloc

ALL

2489

1,033.2 ms

9,712.2 MB

0

1913

769.5 ms

8,023.4 MB

1

382

142.8 ms

1602.3 MB

2

194

120.9 ms

86.5 MB

The PerfView GCStats table compares collection counts, pauses, and allocations by generation. Its Gen2 collections were artificially induced by BenchmarkDotNet, so do not treat their count as ordinary application behavior. section 10.3.4

How .NET in Action, Second Edition covers it

How deep it goes
Explains collection frequency, pause goals, and promotion to Gen1 without detailing collector algorithms.
Examples
Uses a PerfView GCStats table from a BenchmarkDotNet profile to compare generations.
What you can do after
Diagnose/debug with Gen0 statistics when investigating garbage-collection time or unexpected memory use.
How it connects
Connects Gen0 to Gen1, heap compaction, and garbage-collection profiling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.