Files
EdgeNode/internal/utils/mem/system_1.19.go

19 lines
384 B
Go
Raw Permalink Normal View History

2024-07-27 15:42:50 +08:00
// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
2023-03-05 12:34:46 +08:00
//go:build go1.19
2024-03-28 17:17:34 +08:00
package memutils
2023-03-05 12:34:46 +08:00
import (
"runtime/debug"
)
// 设置软内存最大值
func setMaxMemory(memoryGB int) {
if memoryGB <= 0 {
memoryGB = 1
}
2023-10-02 08:18:43 +08:00
2023-11-22 17:03:42 +08:00
var maxMemoryBytes = (int64(memoryGB) << 30) * 80 / 100 // 默认 80%
2023-03-05 12:34:46 +08:00
debug.SetMemoryLimit(maxMemoryBytes)
}