Skip to content

syscall: UTF16FromString is allocating more memory than needed #59967

@freddy77

Description

@freddy77

Using Golang profile tools it looked the function was taking quite a lot of memory so I looked at the code.

What version of Go are you using (go version)?

$ go version
go version devel go1.21-f742ddc Wed May 3 22:13:51 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fziglio/.cache/go-build"
GOENV="/home/fziglio/.config/go/env"
GOEXE=".exe"
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fziglio/go/pkg/mod"
GONOPROXY="repo.jazzdev.io"
GONOSUMDB="repo.jazzdev.io"
GOOS="windows"
GOPATH="/home/fziglio/go"
GOPRIVATE="repo.jazzdev.io"
GOPROXY="https://proxy.golang.org/,direct"
GOROOT="/home/fziglio/work/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/fziglio/work/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.21-f742ddc Wed May 3 22:13:51 2023 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/home/fziglio/work/go/src/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build939632449=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Discovered from a profile, looking at code. Just in case I wrote a test.

What did you expect to see?

Less memory usage

What did you see instead?

More memory usage than expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions