Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly run garbage collection after loading credentials #197

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/calendarsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"runtime"
"time"

"github.com/inovex/CalendarSync/internal/auth"
Expand Down Expand Up @@ -180,6 +181,12 @@ func Run(c *cli.Context) error {
}
log.Info("loaded sink adapter", "adapter", cfg.Sink.Adapter.Type, "calendar", cfg.Sink.Adapter.Calendar)

// By default go runs a garbage collection once the memory usage doubles compared to the last GC run.
// Decrypting the storage in NewSourceAdapterFromConfig/NewSinkAdapterFromConfig requires a lot of memory,
// such that the next GC only trigger once the memory usage double compared to that peak. Explicitly trigger
// a GC to reset the memory usage reference level.
runtime.GC()

if log.GetLevel() == log.DebugLevel {
for _, transformation := range cfg.Transformations {
log.Debug("configured transformer", "name", transformation.Name, "config", transformation.Config)
Expand Down
Loading