Get the latest tech news
Optimizing Heap Allocations in Go: A Case Study
Golang doesn't require users to think about memory allocation. But if you want your code to be fast, you probably should anyway.
The process by which the compiler attempts to prove that a variable can't outlive the current stack from is called escape analysis. If someone reading this has more insight into why Golang thinks that value escapes here, join our Discord and drop me a line and I'll give you a shoutout in my next blog. Storing a value on the heap is always safe in a garbage-collected language, but comes at a performance cost: both during the initial allocation and again during garbage collection.
Or read this on Hacker News