We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Please answer these questions before submitting your issue. Thanks!
go version
go version go1.9.2 linux/amd64
Yes, latest release download from https://golang.org/dl/
go env
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/go" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build363981589=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"
Use map to insert and delete data, code like this:
package main import ( "fmt" "runtime" "runtime/debug" ) func main() { a := make(map[int]int) stats := new(runtime.MemStats) runtime.ReadMemStats(stats) fmt.Printf("Before: %5.2fk\n", float64(stats.Alloc)/1024) previous := stats.Alloc for i := 1000000; i > 0; i-- { a[i] = 0 } for k := range a { delete(a, k) } debug.FreeOSMemory() fmt.Printf("len(a)=%v\n", len(a)) runtime.ReadMemStats(stats) fmt.Printf("After: %5.2fk Added: %5.2fk\n", float64(stats.Alloc)/1024, float64(stats.Alloc-previous)/1024) return }
Memory not increased obviously
Memory increased obviously, output like this:
Before: 42.54k len(a)=0 After: 39252.77k Added: 39210.23k
I do not know why so many memory still exist after i delete all elements in map.
The text was updated successfully, but these errors were encountered:
Dup of #20135.
Sorry, something went wrong.
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
Yes, latest release download from https://golang.org/dl/
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build363981589=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
Use map to insert and delete data, code like this:
What did you expect to see?
Memory not increased obviously
What did you see instead?
Memory increased obviously, output like this:
I do not know why so many memory still exist after i delete all elements in map.
The text was updated successfully, but these errors were encountered: