From f9219588c68559380e55350847df11ef5278dfe1 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Tue, 11 Jul 2023 15:19:52 -0700 Subject: [PATCH] Also run Go garbage collection as part of `Usage.Reduce`. The `Usage.Reduce` RPC's promise is to reclaim as much Sentry memory as possible and to give it back to the host. Seems like running Go GC should be part of that. PiperOrigin-RevId: 547312564 --- pkg/sentry/control/usage.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/sentry/control/usage.go b/pkg/sentry/control/usage.go index b1416a0c8..1a919ab39 100644 --- a/pkg/sentry/control/usage.go +++ b/pkg/sentry/control/usage.go @@ -142,6 +142,8 @@ func (u *Usage) Reduce(opts *UsageReduceOpts, out *UsageReduceOutput) error { if opts.Wait { mf.WaitForEvictions() } + // Also reduce Sentry memory usage by garbage-collecting now. + runtime.GC() return nil }