NBench
NBench copied to clipboard
Distinction between total allocated memory and memory allocated at the end of run
I was trying to find a little bit more about how TotalBytesAllocated
works as it wasn't clear to me at the beginning whether it tries to compute sum of allocations program makes during its run, or whether it measures size of the heap at the end of run.
I think both variants have reasonable use cases: the first one is concerned with memory and GC pressure, the second one is good when looking for memory leaks.
Finally I found GcTotalMemoryCollector
class from which it seems to me that the current implementation is kind of hybrid between the two variants: it's not the sum of allocations as it asks for GC.GetTotalMemory
only once; it also not the total heap size as it refuses to call GetTotalMemory(true)
. It's totally possible I read the code in a wrong way and this reasoning doesn't apply.
I would suggest to
- update documentation that would clarify the meaning of the option;
- think about creating two distinct options with clear use cases.
I'm willing to help if someone more knowledgeable validates my suspicions.