From 78b7f1ddb8d448ead4e42b9a0a5aba38dccc78d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Damick Date: Tue, 28 Jan 2025 12:44:13 -0500 Subject: [PATCH] Force early cleanup of an instance when the instance list is re-sliced on Stop() & Restart() to prevent holding memory Signed-off-by: Jeffrey Damick --- caddy.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/caddy.go b/caddy.go index a868ae06df8..1d1667fb914 100644 --- a/caddy.go +++ b/caddy.go @@ -149,6 +149,7 @@ func (i *Instance) Stop() error { instancesMu.Lock() for j, other := range instances { if other == i { + instances[j] = nil instances = append(instances[:j], instances[j+1:]...) break } @@ -502,6 +503,7 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string][ instancesMu.Lock() for i, otherInst := range instances { if otherInst == inst { + instances[i] = nil instances = append(instances[:i], instances[i+1:]...) break }