优化可用内存检查

This commit is contained in:
GoEdgeLab
2023-04-11 18:52:43 +08:00
parent 2a00799d29
commit 14e7dc72ad

View File

@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package nodes package nodes
@@ -31,7 +32,7 @@ func (this *NodeStatusExecutor) updateMem(status *nodeconfigs.NodeStatus) {
if minFreeMemory > 1<<30 { if minFreeMemory > 1<<30 {
minFreeMemory = 1 << 30 minFreeMemory = 1 << 30
} }
if stat.Free < minFreeMemory { if stat.Available > 0 && stat.Available < minFreeMemory {
runtime.GC() runtime.GC()
debug.FreeOSMemory() debug.FreeOSMemory()
} }