FC61: Complete allocation sequence

Analyzing complete allocation sequence is super powerful

Suppose you have a scenario like using FluentValidation on a single class validation to analyze and optimize. One powerful trick I’ve used over and over again is finding out complete allocation sequence: every type, every allocation, in their nature allocation order.

How would you achieve that? It’s quite easy:

  1. Generate a repro with a big loop,

  2. Run the code and capture a dump,

  3. Walk the Gen0 region to look for a complete sequence using a distinguishable marker,

  4. Write out object information, to a csv file.

  5. Open the .csv file using Excel.

Source code:

Output (for using FluentValidation to validate a customer record):

44 allocations, 2,172 bytes in total. Where else can you get such information? Notice we have addresses for every object, so you can open the dump using windbg/cdb to examine each of them in details.

Now have lots of allocations to remove.