From 96cb5cfc44e218c465cacab884e291ed4d1bb13c Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 26 May 2023 08:12:10 -0700 Subject: [PATCH] fix: limit manual GC to bigger objects (#4581) --- cmd/parallel-manager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/parallel-manager.go b/cmd/parallel-manager.go index 888554fe..9ba01ab2 100644 --- a/cmd/parallel-manager.go +++ b/cmd/parallel-manager.go @@ -195,7 +195,10 @@ func (p *ParallelManager) enoughMemForUpload(uploadSize int64) bool { } smem := runtime.MemStats{} - runtime.GC() + if uploadSize > 50<<20 { + // GC if upload is bigger than 50MB. + runtime.GC() + } runtime.ReadMemStats(&smem) return estimateNeededMemoryForUpload(uploadSize)+smem.Alloc < p.maxMem