

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
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
So the stack is great and all, but one of the downsides is that it has a limited size. If you keep pushing frames onto the stack without popping them off, you'll eventually run out of memory and get a stack overflow. (yes, that's what the famous site is named after)
That's one of the reasons recursion without tail-call optimization can be dangerous. Each recursive call pushes a new frame onto the stack, and if you have too many recursive calls, you'll run out of stack space.
Sneklang is admittedly a fairly inefficient language (don't tell the VC investors!). Sometimes, rather than carefully managing memory, the Sneklang interpreter allocates a big chunk of stack data – simply because the creators (us) are too lazy to allocate the right amount.
Anyhow, the BDFL of Sneklang has allowed this laziness, but only to a maximum amount of 10 kibibytes. A single kibibyte is 1024 bytes.