Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does golang return memory to OS? #42354

Closed
DevRockstarZ opened this issue Nov 3, 2020 · 2 comments
Closed

Does golang return memory to OS? #42354

DevRockstarZ opened this issue Nov 3, 2020 · 2 comments

Comments

@DevRockstarZ
Copy link

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

$ go version
go version go1.15.3 linux/amd64

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=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/workspace/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/workspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build107808986=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I ran the server using golang, but the memory seems to be increasing and it killed by OOM-killer.
Server doesn't return memory to OS.
I set GOGC=50 / GOGC=200 and more, it doesn't seems to be good.
[203213.592974] Out of memory: Killed process 7547 (server) total-vm:40164060kB, anon-rss:31842000kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:68512kB oom_score_adj:0

What did you expect to see?

I expect server returns memory to OS.

@martisch
Copy link
Contributor

martisch commented Nov 3, 2020

Yes it does: https://golang.org/doc/go1.12#runtime See MADV_FREE.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

https://github.com/golang/go/wiki/Questions

@martisch martisch closed this as completed Nov 3, 2020
@davecheney
Copy link
Contributor

Please review #42330 and it’s linked issues.

@golang golang locked and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants