Skip to content

strings: strings.Builder case memory leak  #34463

@szyhf

Description

@szyhf

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

Tried both 1.13.0 and 1.12.9.

$ go version

Does this issue reproduce with the latest release?

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

In docker image alpine:3.8, build cmd is GOOS=linux GOARCH=amd64 go build on macOS 10.14.6

go env Output
$ go env

What did you do?

Using a sync.Pool to reuse strings.Builder.

https://play.golang.org/p/TkWbxGu4PRJ

I use strings.Builder to build sql, and exec the sql-str every times, but I found that the memory will increase slowly, then I called pprof/heap and found that the strings.(*Builder).WriteString inuse a lot of memory and looks never released.

QQ20190923-085002

What did you expect to see?

The memory not increase unexpectedly

What did you see instead?

The memory not increase unexpectedly

Really thanks for help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions