Исходники и презентации
This commit is contained in:
18
lessons/allocator/arena_problem_2/main.go
Normal file
18
lessons/allocator/arena_problem_2/main.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
// GOEXPERIMENT=arenas go run main.go
|
||||
// go run -tags goexperiment.arenas main.go
|
||||
|
||||
import (
|
||||
"arena"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mem := arena.NewArena()
|
||||
defer mem.Free()
|
||||
|
||||
slice := arena.NewSlice[int](mem, 0, 5)
|
||||
slice = append(slice, 1, 2, 3, 4, 5)
|
||||
|
||||
slice = append(slice, 6) // moved to heap
|
||||
}
|
||||
Reference in New Issue
Block a user