diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-15 09:02:49 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-15 09:02:49 -0600 |
| commit | cd4fe3d0a19799ec9a4d61fdd67708a5017d6f07 (patch) | |
| tree | afd80de7b220e23509ffb57ee485c36756b0906f /src/slskd | |
| parent | 7691d9f790ba82b56119089520d280f88d955262 (diff) | |
| download | slskd-cd4fe3d0a19799ec9a4d61fdd67708a5017d6f07.tar.gz | |
use CollectGarbage to collect garbage
Diffstat (limited to 'src/slskd')
| -rw-r--r-- | src/slskd/Core/API/Controllers/ApplicationController.cs | 4 | ||||
| -rw-r--r-- | src/slskd/Search/SearchService.cs | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index 501f8a9c..19360fe1 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -19,7 +19,6 @@ namespace slskd.Core.API { using System; using System.Diagnostics; - using System.Runtime; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -128,8 +127,7 @@ namespace slskd.Core.API [Authorize] public IActionResult CollectGarbage() { - GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; - GC.Collect(2, GCCollectionMode.Forced, blocking: false, compacting: true); + Application.CollectGarbage(); return Ok(); } diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index e529f738..b934e86b 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -45,16 +45,19 @@ namespace slskd.Search /// </summary> /// <param name="optionsMonitor"></param> /// <param name="soulseekClient"></param> + /// <param name="application"></param> /// <param name="contextFactory">The database context to use.</param> /// <param name="log">The logger.</param> public SearchService( IOptionsMonitor<Options> optionsMonitor, ISoulseekClient soulseekClient, + IApplication application, IDbContextFactory<SearchDbContext> contextFactory, ILogger<SearchService> log) { OptionsMonitor = optionsMonitor; Client = soulseekClient; + Application = application; ContextFactory = contextFactory; Log = log; } @@ -63,6 +66,7 @@ namespace slskd.Search = new ConcurrentDictionary<Guid, CancellationTokenSource>(); private IOptionsMonitor<Options> OptionsMonitor { get; } + private IApplication Application { get; } private ISoulseekClient Client { get; } private IDbContextFactory<SearchDbContext> ContextFactory { get; } private ILogger<SearchService> Log { get; set; } @@ -130,6 +134,7 @@ namespace slskd.Search finally { CancellationTokens.TryRemove(id, out _); + Application.CollectGarbage(); } } |
