Skip to content

Instantly share code, notes, and snippets.

@yumed15
Created November 22, 2023 10:04
Show Gist options
  • Save yumed15/2784561f2007e90634a4af2575adf5c2 to your computer and use it in GitHub Desktop.
Save yumed15/2784561f2007e90634a4af2575adf5c2 to your computer and use it in GitHub Desktop.
func f1() **int {
// t escapes to heap
t := 0
// x1 escapes to heap
x1 := &t
return &x1
}
func f2() *int {
// t escapes to heap
t := 0
x2 := &t
return x2
}
func f3() int {
t := 0
x3 := t
return x3
}
func f4() map[string]int {
// kv escapes to heap
kv := make(map[string]int)
return kv
}
func f5() []int {
// s escapes to heap
s := []int{}
return s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment