manual trigger GC in import and export

This commit is contained in:
2025-04-26 10:44:48 -01:06
parent 53c08ec246
commit ab867a3eb4
3 changed files with 6 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io"
"runtime/debug"
"github.com/dgraph-io/badger/v4"
@@ -224,6 +225,7 @@ func (r *T) BlanketDownload(c context.T, w io.Writer) (counter int, err error) {
counter++
if counter%1000 == 0 && counter > 0 {
log.I.F("%d events exported", counter)
debug.FreeOSMemory()
}
}
return

View File

@@ -3,7 +3,7 @@ package ratel
import (
"bufio"
"io"
"time"
"runtime/debug"
"realy.lol/chk"
"realy.lol/event"
@@ -36,9 +36,9 @@ func (r *T) Import(rr io.Reader) {
b = nil
ev = nil
count++
if count%1000 == 0 {
if count%100 == 0 {
log.I.F("received %d events", count)
time.Sleep(time.Second)
debug.FreeOSMemory()
}
}
log.I.F("read %d bytes and saved %d events", total, count)

View File

@@ -1 +1 @@
v1.16.4
v1.16.5