change cache

This commit is contained in:
yourok
2019-09-23 09:25:59 +03:00
parent 2b286c15c1
commit 3db98a79b7

View File

@@ -20,9 +20,18 @@ func FreeOSMem() {
debug.FreeOSMemory()
}
func FreeOSMemGC() {
runtime.GC()
debug.FreeOSMemory()
func FreeOSMemGC(maxAlloc int64) {
if maxAlloc <= 0 {
runtime.GC()
debug.FreeOSMemory()
return
}
var m runtime.MemStats
runtime.ReadMemStats(&m)
if m.Alloc > uint64(float32(maxAlloc)*2) {
runtime.GC()
debug.FreeOSMemory()
}
}
const (