golang/go
View on GitHubruntime: allow `GOMEMLIMIT` to parse non integer values with a suffix like `1.5GiB` → `1536MiB`
Open
#76923 opened on Dec 19, 2025
FeatureRequestFixPendingLibraryProposalcompiler/runtimehelp wanted
Description
Go version
go version go1.25.5 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w4/9h406zs53_d82t0jx555j4ww0000gn/T/go-build2324368129=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/tmp/testgo/go.mod'
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.5/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/user/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.5'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
GOMEMLIMIT=1.5GiB go run .
What did you see happen?
GOMEMLIMIT=1.5GiB
fatal error: malformed GOMEMLIMIT; see `go doc runtime/debug.SetMemoryLimit`
runtime stack:
runtime.throw({0x10337f090?, 0xa?})
runtime/panic.go:1094 +0x34 fp=0x16d03eeb0 sp=0x16d03ee80 pc=0x102e367d4
runtime.readGOMEMLIMIT()
runtime/mgcpacer.go:1365 +0xb4 fp=0x16d03eee0 sp=0x16d03eeb0 pc=0x102de9c14
runtime.gcinit()
runtime/mgc.go:189 +0x38 fp=0x16d03ef10 sp=0x16d03eee0 pc=0x102de0318
runtime.schedinit()
runtime/proc.go:898 +0x1c0 fp=0x16d03ef80 sp=0x16d03ef10 pc=0x102e02b70
runtime.rt0_go()
runtime/asm_arm64.s:121 +0xcc fp=0x16d03efb0 sp=0x16d03ef80 pc=0x102e3c6dc
What did you expect to see?
According to the documentation GOMEMLIMIT is a numeric value with an optional unit suffix:
https://github.com/golang/go/blob/d00e96d3aeccb11c373d125418316f0b019f4fb0/src/runtime/extern.go#L27-L33
And numeric types include: https://github.com/golang/go/blob/d00e96d3aeccb11c373d125418316f0b019f4fb0/doc/go_spec.html#L841-L846
However, GOMEMLIMIT only accepts integers:
https://github.com/golang/go/blob/d00e96d3aeccb11c373d125418316f0b019f4fb0/src/runtime/string.go#L402-L415
Therefore, I would expect GOMEMLIMIT to either accept a float value or explicitly specify the types it accepts. For instance, systemd allows specifying memory constraints using a float value with a suffix.