Исходники и презентации
This commit is contained in:
18
lessons/allocator/allocation_5/main.go
Normal file
18
lessons/allocator/allocation_5/main.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
// -l = disable inlining
|
||||
// -m = print optimization decisions
|
||||
// go build -gcflags '-l -m'
|
||||
|
||||
func createPointer() *int {
|
||||
value2 := new(int)
|
||||
return value2
|
||||
}
|
||||
|
||||
func main() {
|
||||
value1 := new(int) // stack
|
||||
_ = value1
|
||||
|
||||
value2 := createPointer() // heap
|
||||
_ = value2
|
||||
}
|
||||
Reference in New Issue
Block a user