I have been taught to use the stack as little as possible. For instance when I need a large temporary buffer I was told to use the heap. I understand that one reason for this might be that the stack size is limited on most systems. If there is no fear of overflowing the stack, wouldn't allocating memory on the stack be faster than allocating it on the heap? To deallocate it, the system just needs to change the position of the frame pointer when the function that created it returns. Right? It seams like allocating and deallocating memory on the heap using new and delete is slower. Besides I like the fact that stack memory is automatically cleaned up for me.
Any comments?
Also, what is the maximum stack size for user applications on win32, linux86, ...?