- 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.
- 數據庫技術與應用教程(Access)
- 數據結構與算法(C語言版)
- iOS and OS X Network Programming Cookbook
- 大數據Hadoop 3.X分布式處理實戰
- Python金融數據分析(原書第2版)
- LabVIEW 完全自學手冊
- 數據科學工程實踐:用戶行為分析與建模、A/B實驗、SQLFlow
- 新基建:數據中心創新之路
- Oracle RAC日記
- Hands-On System Programming with C++
- Oracle 內核技術揭密
- 數據庫技術與應用:SQL Server 2008
- 大學計算機:理解和運用計算思維
- Learning Construct 2
- 數據庫高效優化:架構、規范與SQL技巧