Here is my golang code to set a key C to value 1 in redis
It uses third party code in order to connect to redis.
package main
import (
"github.com/garyburd/redigo/redis"
)
func main() {
c, err := redis.Dial("tcp", ":6379")
_, err = c.Do("SET", "C", 1)
if err != nil {
panic(err)
}
}
On doing go build -gcflags "-m -m"
, it reports
./del.go:41: 1 escapes to heap
./del.go:41: from c.Do("SET", "C", 1) (parameter to indirect call) at ./del.go:41
Why does 1 escape to the heap ? It is a simple constant whose complete information is known at compile time and it takes just 64bits on a 64bit system. Why should it be stored in heap memory?