AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
How to Control What Goes on the Stack
When you create a local variable, for instance, it's going to be on the stack or when you pass an argument to a function, it's probably on the end of the stack. The place where this kind of gets complicated is that what's not on the stack, which is things that are on the heap. And so overall, the general idea is put as much things on the stack because the stack, as David said, is scratch storage. It does not need the garbage collector. Only if you need to use pointers and only if you need something on the heap, you'll do that just to avoid the overhead of the garbage collector running.