Skip to content

Commit

Permalink
Update garbage collection settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Apr 15, 2024
1 parent a9058ce commit cea2d33
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy
# libgomp needed for thot
RUN apt update && apt install -y unzip libgomp1 && \
curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /remote_debugger
curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /remote_debugger
RUN dotnet tool install --global dotnet-counters
ENV PATH="${PATH}:~/.dotnet/tools"
4 changes: 4 additions & 0 deletions src/SIL.Machine.AspNetCore/Services/HangfireBuildJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ CancellationToken cancellationToken
}

await DoWorkAsync(engineId, buildId, data, buildOptions, @lock, cancellationToken);
// actively clear out memory when the job is complete.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
catch (OperationCanceledException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ await _stateService.CommitAsync(
_engineOptions.CurrentValue.InactiveEngineTimeout,
cancellationToken
);
// We've just cleared some things out of memory, so let's do a garbage collection.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"configProperties": {
"System.GC.Server": true,
"System.GC.Concurrent": true,
"System.GC.ConserveMemory": 5,
"System.GC.HighMemoryPercent": 80
}
}
8 changes: 8 additions & 0 deletions src/SIL.Machine.Serval.JobServer/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"configProperties": {
"System.GC.Server": true,
"System.GC.Concurrent": true,
"System.GC.ConserveMemory": 5,
"System.GC.HighMemoryPercent": 80
}
}

0 comments on commit cea2d33

Please sign in to comment.