-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryProfiler.cs
36 lines (31 loc) · 1 KB
/
MemoryProfiler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DotNetMemoryUtilization
{
public static class MemoryProfiler
{
static Process currentProcess;
static StringBuilder sb;
public static void LogHeader()
{
Debug.WriteLine($@"DumpUsedMemory{'\t'}PagedMemorySize64{'\t'}PeakPagedMemorySize64{'\t'}PrivateMemorySize64{'\t'}VirtualMemorySize64");
}
public static void LogMemoryFootPrint(int arg)
{
sb = new StringBuilder();
currentProcess = System.Diagnostics.Process.GetCurrentProcess();
//x64
sb.Append($@"{arg.ToString("00000")}");
sb.Append($@"{'\t'}{currentProcess.PagedMemorySize64}");
sb.Append($@"{'\t'}{currentProcess.PeakPagedMemorySize64}");
sb.Append($@"{'\t'}{currentProcess.PrivateMemorySize64}");
sb.Append($@"{'\t'}{currentProcess.VirtualMemorySize64}");
Debug.WriteLine(sb.ToString());
sb = null;
}
}
}