

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: The Stack
incomplete
2: Why a Stack?
incomplete
3: Stack Overflow
incomplete
4: Pointers to the Stack
incomplete
5: The Heap
incomplete
6: Malloc
incomplete
7: Free
incomplete
8: Big Endian and Little Endian
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Allocating memory on the stack is preferred when possible because the stack is faster and simpler than the heap (which we'll get to, be patient):
One reason Go programs are efficient is that Go uses stack allocation for variables when possible, much like C. The Go compiler performs escape analysis to decide whether a variable can be allocated on the stack. On the other hand, languages like Python allocate most objects on the heap, which can impact performance.