- C# 7 and .NET Core 2.0 High Performance
- Ovais Mehboob Ahmed Khan
- 175字
- 2021-08-27 18:47:14
Memory diagnostics using BenchmarkDotnet
With BenchmarkDotnet, we can also diagnose any problems with the memory and measure the number of allocated bytes and garbage collection.
It can be implemented using a MemoryDiagnoser attribute at the class level. To start, let's just add the MemoryDiagnoser attribute to the TestBenchmark class that we created in the last example:
[MemoryDiagnoser] public class TestBenchmark {}
Rerun the application. Now it will collect other memory allocation and garbage collection information and generate logs accordingly:

In the preceding table, the Gen 0 and Gen 1 columns each contain the number of that particular generation per 1,000 operations. If the value is 1, then it means that the garbage collection was done after 1,000 operations. However, note that in the first row, the value is 0.1984, which means that the garbage collection was done after 198.4 seconds, whereas for Gen 1 of that row, no garbage collection took place. Allocated represents the size of the memory that is allocated while invoking that method. It does not include the Stackalloc/heap native allocations.
- App+軟件+游戲+網站界面設計教程
- 云計算與大數據應用
- Python醫學數據分析入門
- INSTANT Apple iBooks How-to
- 新手學會計(2013-2014實戰升級版)
- 計算機組裝與維護(微課版)
- Python數據分析從小白到專家
- 計算機視覺
- Internet of Things with Python
- 大數據分析:R基礎及應用
- AndEngine for Android Game Development Cookbook
- Visual Studio 2012 and .NET 4.5 Expert Development Cookbook
- Artificial Intelligence for Big Data
- 深入理解Flink:實時大數據處理實踐
- Mastering Java for Data Science