James Sutherland jas88@cam.ac.uk writes:
Last time this came up, someone had found the stack overflowing with a large allocation - something like the char foo[10*1024] Patrik mentions - and moved it to malloc(). At which point, someone else suggested turning the malloc() into an alloca(), since it's faster...
At the time, there were some fairly tight stack constraints in places. Have these disappeared, or is alloca() still the wrong thing to do???
The stack space is limited to 1Mb per thread (unless the application changed the defaults); it's not very tight, but it still means we cannot allocate arbitrary-sized data.