Repository navigation
Closed as not planned
Labels
FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
Description
What version of Go are you using (go version)?
$ go version go version go1.17.9 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="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/data/bin/codis/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/data/bin/codis" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.9" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build356646192=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I run elasticsearch bulk updates in goroutine. In goroutine, continually read update params from channel (about 20/s) and generate update string using this(below) code.
// getUpdateStr generate bulk update string of elastic search
func getUpdateStr(chunk []*params, length int) string {
s := make([]string, length)
for i, p := range chunk {
if i >= length {
break
}
s[i] = p.toEsBulkStr()
}
return strings.Join(s, "")
}What did you expect to see?
stable memory
What did you see instead?
increasing memory
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.

Activity
randall77 commentedon Aug 2, 2022
What happens to the strings that are returned? Are they being saved somewhere?
The allocations that
strings.Joindoes should only survive a garbage collection if the returned string is retained by something.[-]affected/package: strings.Join memory leak[/-][+]strings: strings.Join memory leak[/+][-]strings: strings.Join memory leak[/-][+]strings: Join memory leak[/+]CodeisCold commentedon Aug 2, 2022
strings are used by
strings.NewReader:randall77 commentedon Aug 2, 2022
They end up in
b.c.Bulk, whatever that does.I don't think it is efficient to debug this back and forth on an issue. If you can, please try to build a reproducible example that we can run ourselves.
I suspect something is hanging on to the results. Nothing in the implementation of
strings.Joinlooks suspicious.thediveo commentedon Aug 2, 2022
I notice this additional "consumption":
what log do you use?
CodeisCold commentedon Aug 3, 2022
logrus
CodeisCold commentedon Aug 3, 2022
It's a bug of
elastic/go-elasticsearch/v7.Reproducible Code:
seankhliao commentedon Aug 3, 2022
Closing as not a bug in std
CodeisCold commentedon Aug 3, 2022
The bug is that I didn't call the
Close()method of es Bulk Response.The flame graph looks weird. Total memory in flame graph is much less than real memory used by project