diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-15 09:06:28 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-15 09:06:28 -0600 |
| commit | df49c7e5fe5a0e145d5605087fe6df9897106a7f (patch) | |
| tree | 44442b4aa09e6ac1c18f8784dc1b229ff7f0b784 /src | |
| parent | cd4fe3d0a19799ec9a4d61fdd67708a5017d6f07 (diff) | |
| download | slskd-df49c7e5fe5a0e145d5605087fe6df9897106a7f.tar.gz | |
log garbage collection
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index f893cae1..6ce17bf5 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -21,6 +21,7 @@ namespace slskd { using System; using System.Collections.Concurrent; + using System.Diagnostics; using System.IO; using System.Linq; using System.Net; @@ -139,10 +140,20 @@ namespace slskd public void CollectGarbage() { + var sw = new Stopwatch(); + + Log.Debug("Collecting garbage"); + + sw.Start(); + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; #pragma warning disable S1215 // "GC.Collect" should not be called GC.Collect(2, GCCollectionMode.Forced, blocking: false, compacting: true); #pragma warning restore S1215 // "GC.Collect" should not be called + + sw.Stop(); + + Log.Debug("Garbage collection completed in {Duration}ms", sw.ElapsedMilliseconds); } /// <summary> |
