Просмотр исходного кода

Aggressively return memory back to OS while combining

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 лет назад
Родитель
Сommit
06cdb909f3
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      cmd/hercules/combine.go

+ 3 - 0
cmd/hercules/combine.go

@@ -7,6 +7,7 @@ import (
 	"io"
 	"io/ioutil"
 	"os"
+	"runtime/debug"
 	"sort"
 	"strings"
 
@@ -46,6 +47,7 @@ var combineCmd = &cobra.Command{
 		bar.ShowPercent = false
 		bar.ShowSpeed = false
 		bar.SetMaxWidth(80).Start()
+		debug.SetGCPercent(20)
 		for _, fileName = range files {
 			bar.Increment()
 			anotherResults, anotherMetadata, errs := loadMessage(fileName, &repos)
@@ -53,6 +55,7 @@ var combineCmd = &cobra.Command{
 				mergeResults(mergedResults, mergedMetadata, anotherResults, anotherMetadata)
 			}
 			allErrors[fileName] = errs
+			debug.FreeOSMemory()
 		}
 		bar.Finish()
 		printErrors(allErrors)