Slide 8
Slide 8 text
©2022 Wantedly, Inc.
༨ஊIFBQ
TUBDLͲͪΒ͕ΘΕ͍ͯΔ͔
package main
import "fmt"
func main() {
slice
:=
make([]int64, 0, 0)
fmt.Println(slice)
c
:=
make(chan string)
fmt.Println(c)
s
:=
"string"
fmt.Println(s)
}
:) % go build -gcflags '-m' alloc_playground.go
# command-line-arguments
./alloc_playground.go:7:13: inlining call to fmt.Println
./alloc_playground.go:10:13: inlining call to fmt.Println
./alloc_playground.go:13:13: inlining call to fmt.Println
./alloc_playground.go:6:15: make([]int64, 0, 0) escapes to heap
./alloc_playground.go:7:13: slice escapes to heap
./alloc_playground.go:7:13: []interface {}{
...
} does not escape
./alloc_playground.go:10:13: []interface {}{
...
} does not escape
./alloc_playground.go:13:13: s escapes to heap
./alloc_playground.go:13:13: []interface {}{
...
} does not escape
:
1: .this does not escape
• -gcflags “-m”Λ͚ͭΔͱ͔Δ