runtime: potential memory leak in Go1.11.2 #29185
Comments
How many iterations have you tried? |
With this repro on package main
import (
"fmt"
"runtime"
"time"
)
func main() {
for {
time.Sleep(time.Second)
// runtime.GC() // this is optional
var memstats runtime.MemStats
runtime.ReadMemStats(&memstats)
// println(memstats.Alloc)
fmt.Printf("%db\n", memstats.Alloc)
}
} And running
But if I comment out the I really doubt |
Is it because Using
Using println
I think it is common for the escape analysis to allocate on the heap, if the function takes in an interface type. |
Thank you all for the detailed feedback! From what I've understood this is the expected behaviour (memory increase until GC kicks in). Closing for now, please let me know if I did misunderstand the feedback. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I realize this is very unlikely but I wouldn't expect this simple loop to show increasing memory usage:
What did you expect to see?
Consant memory usage
What did you see instead?
Rising memory:
Omitting the
GC()
call makes the memory rise quicker in smaller steps.The text was updated successfully, but these errors were encountered: