MCPcopy Create free account
hub / github.com/actiontech/dtle / IsLowMemory

Function IsLowMemory

g/g.go:114–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112}
113
114func IsLowMemory() bool {
115 //return atomic.LoadInt32(&lowMemory) == 1
116 memory, err := mem.VirtualMemory()
117 if err != nil {
118 return false
119 }
120 if ((memory.Available * 10) < (memory.Total * 2)) && (memory.Available < 1*1024*1024*1024) {
121 if !lowMemory {
122 Logger.Warn("memory is less than 20% and 1GB. pause parsing binlog",
123 "available", memory.Available, "total", memory.Total)
124 }
125 lowMemory = true
126 return true
127 } else {
128 if lowMemory {
129 Logger.Info("memory is greater than 20% or 1GB. continue parsing binlog",
130 "available", memory.Available, "total", memory.Total)
131 }
132 lowMemory = false
133 return false
134 }
135}
136
137func MemoryMonitor(logger LoggerType) {
138 if !atomic.CompareAndSwapInt32(&memoryMonitorCount, 0, 1) {

Callers 2

DataStreamEventsMethod · 0.92
MemoryMonitorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected