aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/slskd/Core/API/Controllers/ApplicationController.cs4
-rw-r--r--src/slskd/Search/SearchService.cs5
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();
}
}