- Frugal Cafe
- Posts
- FC61: Complete allocation sequence
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:
Generate a repro with a big loop,
Run the code and capture a dump,
Walk the Gen0 region to look for a complete sequence using a distinguishable marker,
Write out object information, to a csv file.
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.