Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.8 darwin/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/anon/base/code/golang/"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b8/3rkdjmp97bsbgsf5pn7xcwlw0000gn/T/go-build995600224=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
Introduced a 1 millisecond sleep timer into a goroutine before returning
https://play.golang.org/p/N5-mzj9Ywk
What did you expect to see?
Garbage collection.
What did you see instead?
No garbage collection.
Notes
There are two main functions in the go-playground exmaple..
runSpawner and runSpawner2
If you run spawner 1 before spawner 2 no garbage collection happens.
But if you reverse the order, spawner 2 child processes get garbage collected.
I don't know why this happens.. but it seems a sleep timer within a goroutine stops it ( and future processes ) from getting garbage collected ?