Improve oom-killer

This commit is contained in:
世界
2026-04-28 08:18:08 +08:00
parent cc238d20a2
commit 4c9978fc30
7 changed files with 45 additions and 10 deletions
+9 -5
View File
@@ -105,6 +105,7 @@ type adaptiveTimer struct {
limitThresholds pressureThresholds
access sync.Mutex
cleanupTriggered bool
timer *time.Timer
state pressureState
currentInterval time.Duration
@@ -161,10 +162,6 @@ func (t *adaptiveTimer) stop() {
}
func (t *adaptiveTimer) poll() {
if t.timerConfig.policyMode == policyModeNetworkExtension {
runtimeDebug.FreeOSMemory()
}
var triggered bool
var rateTriggered bool
sample := readMemorySample(t.policyMode)
@@ -174,6 +171,12 @@ func (t *adaptiveTimer) poll() {
t.access.Unlock()
return
}
if t.timerConfig.policyMode == policyModeNetworkExtension {
if t.cleanupTriggered {
runtimeDebug.FreeOSMemory()
t.cleanupTriggered = true
}
}
if t.pendingPressureBaseline {
t.pressureBaseline = sample
t.pressureBaselineTime = time.Now()
@@ -205,10 +208,10 @@ func (t *adaptiveTimer) poll() {
}
}
t.access.Unlock()
if !triggered {
return
}
t.cleanupTriggered = false
t.onTriggered(sample.usage)
if rateTriggered {
if t.killerDisabled {
@@ -225,6 +228,7 @@ func (t *adaptiveTimer) poll() {
t.router.ResetNetwork()
}
}
badCleanup()
runtimeDebug.FreeOSMemory()
}