What is the memory footprint of following code something like number of objects on heap.
for (int i = 0; i < 10000; i++)
{
await MyMethod();
}
What is the memory footprint of following code something like number of objects on heap.
for (int i = 0; i < 10000; i++)
{
await MyMethod();
}
This question is probably a duplicate.
But the following calls to the VirtualMemorySize64
method will get you the current size of the memory in bytes. If you wrap the operation you want to monitor and grab a snapshot before and after you can work out the total increase here.
Docs link here.
using System.Diagnostics;
...
long start = Process.GetCurrentProcess().VirtualMemorySize64;
for (int i = 0; i < 10000; i++)
{
await MyMethod();
}
long end = Process.GetCurrentProcess().VirtualMemorySize64;
// You can then get the total difference in bytes
long diff = end - start;