On Tue, 31 Jan 2006, Olwe Bottorff wrote: > Okay, when I use a malloc or alloca, I'm grabbing heap > memory, but if I just initialize a variable, array, > etc. and fill it with stuff, I'm using stack > "automatic" memory, right? But of course a malloc > inside a function uses heap. And in general if you > don't know or have big memory needs, use heap memory, > right? alloca allocates from the stack as well, like local variables. Which is why it automatically goes away when you return from the function you alloca()'d in. But yeah, if you're allocating large hunks of memory, do it on the heap and not on the stack. The stack is limited (often to only a few megabytes), to prevent things like infinite recursion. Heap is only limited by the address space limitations (and the total amount of memory+swap on the computer). Brian