From 8274ce41df7c51cd0986174a637590c17aa5dff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 7 Jul 2026 19:09:50 +0800 Subject: [PATCH] daemon: Release memory to OS on service reload --- daemon/started_service.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/started_service.go b/daemon/started_service.go index a0cf0b6f8..e33cdfbbb 100644 --- a/daemon/started_service.go +++ b/daemon/started_service.go @@ -4,6 +4,7 @@ import ( "context" "os" "runtime" + runtimeDebug "runtime/debug" "sync" "time" @@ -190,6 +191,7 @@ func (s *StartedService) StartOrReloadService(profileContent string, options *Ov s.updateStatus(ServiceStatus_STOPPING) s.serviceAccess.Unlock() _ = oldInstance.Close() + runtimeDebug.FreeOSMemory() s.serviceAccess.Lock() } s.updateStatus(ServiceStatus_STARTING) @@ -216,7 +218,7 @@ func (s *StartedService) StartOrReloadService(profileContent string, options *Ov s.startedAt = time.Now() s.updateStatus(ServiceStatus_STARTED) s.serviceAccess.Unlock() - runtime.GC() + runtimeDebug.FreeOSMemory() return nil } @@ -247,7 +249,7 @@ func (s *StartedService) CloseService() error { s.startedAt = time.Time{} s.updateStatus(ServiceStatus_IDLE) s.serviceAccess.Unlock() - runtime.GC() + runtimeDebug.FreeOSMemory() return nil }