Proposal
The Automatically set GOMEMLIMIT to match Linux container or system memory limit functionality currently initializes GOMEMLIMIT only once at startup by invoking memlimit.SetGoMemLimitWithOpts with memlimit.WithRatio as the sole option. Consequently, if the container’s cgroup memory limit changes during runtime, for example, when a Vertical Pod Autoscaler (VPA) updates resource limits, the Go runtime’s GOMEMLIMIT remains unchanged and continues to reflect the value determined at startup.
The underlying automemlimit library already supports periodically refreshing the memory limit via WithRefreshInterval, which could be used to ensure GOMEMLIMIT stays synchronized with runtime cgroup memory limit changes.
Proposal
The Automatically set
GOMEMLIMITto match Linux container or system memory limit functionality currently initializesGOMEMLIMITonly once at startup by invokingmemlimit.SetGoMemLimitWithOptswithmemlimit.WithRatioas the sole option. Consequently, if the container’s cgroup memory limit changes during runtime, for example, when a Vertical Pod Autoscaler (VPA) updates resource limits, the Go runtime’sGOMEMLIMITremains unchanged and continues to reflect the value determined at startup.The underlying
automemlimitlibrary already supports periodically refreshing the memory limit viaWithRefreshInterval, which could be used to ensureGOMEMLIMITstays synchronized with runtime cgroup memory limit changes.