Skip to content

Commit 15e0164

Browse files
AspectTheDevaustinv900
authored andcommitted
Add hook memory
1 parent a622cfa commit 15e0164

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Plugins/Plugin.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public bool IsCorePlugin
140140
/// </summary>
141141
/// <value>The total hook time.</value>
142142
public double TotalHookTime { get; internal set; }
143+
public long TotalHookMemory { get; internal set; }
144+
private long _currentMemoryUsed { get; set; }
143145

144146
// Used to measure time spent in this plugin
145147
private Stopwatch trackStopwatch = new Stopwatch();
@@ -346,6 +348,7 @@ public void TrackStart()
346348
return;
347349
}
348350

351+
_currentMemoryUsed = GetMemory();
349352
stopwatch.Start();
350353
}
351354

@@ -364,9 +367,13 @@ public void TrackEnd()
364367

365368
stopwatch.Stop();
366369
TotalHookTime += stopwatch.Elapsed.TotalSeconds;
370+
TotalHookMemory += Math.Max(0, GetMemory() - _currentMemoryUsed);
367371
stopwatch.Reset();
368372
}
369373

374+
private static long GetMemory()
375+
=> GC.GetTotalMemory(false);
376+
370377
#region Config
371378

372379
/// <summary>

0 commit comments

Comments
 (0)