golang/go

wiki: allocfreetrace=1 doesn't work & traceallocfree is not documented

Open

#75,183 建立於 2025年8月28日

在 GitHub 查看
 (8 留言) (0 反應) (1 負責人)Go (133,883 star) (19,008 fork)batch import
DocumentationNeedsFixcompiler/runtimehelp wanted

描述

Go version

go version go1.25.0 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/glen/.local/share/mise/installs/go/1.25.0/bin'
GOCACHE='/Users/glen/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/glen/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/0y/vtlpbcf55j1_jvbs92x2fsrh0000gn/T/go-build849456377=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/glen/Development/Geckoboard/turnstile/go.mod'
GOMODCACHE='/Users/glen/go/pkg/mod'
GONOPROXY='github.com/geckoboard'
GONOSUMDB='github.com/geckoboard'
GOOS='darwin'
GOPATH='/Users/glen/go'
GOPRIVATE='github.com/geckoboard'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/glen/.local/share/mise/installs/go/1.25.0'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/glen/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/glen/.local/share/mise/installs/go/1.25.0/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I am attempting to get a trace of allocations being performed on a small amount of code for optimization purposes

As documented here: https://go.dev/wiki/Performance#memory-allocator-trace

So I ran

GODEBUG=traceallocfree=1 go test .

What did you see happen?

Just the output of my tests running

What did you expect to see?

When running under Go 1.19 the flag produces large amounts of allocation trace information

I was able to find https://github.com/golang/go/issues/68885, which has been closed and locked, and links to https://go-review.googlesource.com/c/go/+/583376 - however that CL does not reference any related Go issue or explanation.

I can see a related CL https://go-review.googlesource.com/c/go/+/583377/4 that refers to a GODEBUG of traceallocfree, but I can find no further reference to this anywhere else, and enabling it when executing a binary does not appear to do anything

What is the current state of allocation tracing?

貢獻者指南