Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Visual C++: Stack Overflow

📅 2006-Jun-09 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ stacks, visual c++ ⬩ 📚 Archive

On Visual C++ 2005, I allocated a large local array in a function. The program got a stack overflow exception and ended inside chkstk.asm.

 
 
 
 

I am used to the stack size limit on Linux/Cygwin which is usually 2MB.

The limit can be found using the bash builtin command ulimit:

$ ulimit -s
2042 (KB)

But, the array I was allocating under VC++ 2005 was just a bit larger than 1MB. On further digging, I found that the default stack size on VC++ 2005 is 1MB.

This stack size limit can be modified using: Project → Properties → Configuration Properties → Linker → System → Stack Reserve Size.

 
 

More information on the stack size limit can be found from the MSDN page on /STACK linker option.