Skip to content

cmd/compile: compiling large packages uses too much memory #79444

Description

@pgimalac

Go version

1.25.10, devel

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='auto'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/bits/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/bits/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build119335857=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/bits/pgimalac/go/src/go.mod'
GOMODCACHE='/home/bits/go/pkg/mod'
GONOPROXY=''
GONOSUMDB='github.com/DataDog,go.ddbuild.io'
GOOS='linux'
GOPATH='/home/bits/go'
GOPRIVATE=''
GOROOT='/home/bits/pgimalac/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/bits/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/bits/pgimalac/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27-devel_9df04115d6 Sat May 16 21:31:02 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Compile large Go packages (eg. github.com/aws/aws-sdk-go-v2/service/ec2 or github.com/DataDog/datadog-api-client-go/v2/api/datadogV2) on a VM with only 4GB of memory.

What did you see happen?

Big memory usage, go tool compile gets OOM killed.

On a big VM, running go tool compile for github.com/aws/aws-sdk-go-v2/service/ec2 under time -v with a single proc shows around 2.7GB peek memory usage.

Relates to aws/aws-sdk-go-v2#2871.

What did you expect to see?

Lower memory usage, should work properly even on small VMs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions