Step 3 of 6
Stack vs. heap memory
The stack is a tidy, short-lived scratchpad for each function call: it's cleaned up automatically when the function returns. The heap is a big shared space for data that needs to stick around (objects, lists, user sessions). Heap memory has to be freed, either by you (C) or by a garbage collector (JavaScript, Python).
Why it matters when you build with AI: 'Maximum call stack size exceeded' means a function kept calling itself and filled the stack. A server that slowly uses more and more RAM usually means something is holding on to heap memory it no longer needs.
Quick check
'Maximum call stack size exceeded' usually means…
Each call adds a stack frame. Endless recursion fills the stack.