From c1ea20c31218220d325826f0d2b121651309c2fe Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 13 Nov 2021 13:00:08 -0600 Subject: bump dependencies, add route to force garbage collection --- src/slskd/Core/API/Controllers/ApplicationController.cs | 15 +++++++++++++++ src/slskd/slskd.csproj | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index 16cd68b9..a7168efb 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -19,6 +19,7 @@ namespace slskd.Core.API { using System; using System.Diagnostics; + using System.Runtime; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -111,5 +112,19 @@ namespace slskd.Core.API return Ok(ApplicationStateMonitor.CurrentValue.Version); } + + /// + /// Forces garbage collection. + /// + /// + [HttpPost("gc")] + [Authorize] + public async Task CollectGarbage() + { + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(2, GCCollectionMode.Forced, blocking: false, compacting: true); + + return Ok(); + } } } diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index 124238e4..58f7cfe0 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -64,11 +64,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive -- cgit v1.2.3