Closed AmitKumarDas closed 2 years ago
// https://mastanca.medium.com/my-raw-notes-on-go-best-practices-concurrency-memory-and-beyond-5d82c1dae110
//
// Sharing down typically stays on the stack
// Sharing up typically escapes to the heap
// Only the compiler knows for sure when typically is not typically
// To get accurate information build your program with gcflags
go build -gcflags=”-m -l” program.go
// When does a variable escape to the heap?
// - If it could possibly be referenced after the function returns
// - When a value is too big for the stack
// - When the compiler doesn’t know the size in compile time