diff --git a/garbagecollector.go b/garbagecollector.go index 49d4090..2d18363 100644 --- a/garbagecollector.go +++ b/garbagecollector.go @@ -1,29 +1,10 @@ package main import ( - "log" - "runtime" - "time" + "runtime/debug" ) func initGC() { - go func() { - ticker := time.NewTicker(15 * time.Minute) - for range ticker.C { - doGC() - } - }() -} - -func doGC() { - var before, after runtime.MemStats - runtime.ReadMemStats(&before) - runtime.GC() - runtime.ReadMemStats(&after) - log.Printf( - "\nAlloc: %d MiB -> %d MiB\nSys: %d MiB -> %d MiB\nNumGC: %d", - before.Alloc/1024/1024, after.Alloc/1024/1024, - before.Sys/1024/1024, after.Sys/1024/1024, - after.NumGC, - ) + // Set memory limit to 100 MB + debug.SetMemoryLimit(100 * 1000 * 1000) }