Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio C/C++ Array Size Unhandled exception Stack overflow [duplicate]

Possible Duplicate:
What is a stack overflow error?

It just happens when I declare large arrays with the size of 4096*1024

First-chance exception at 0x01382e97 in nsfclient.exe: 0xC00000FD: Stack overflow.
Unhandled exception at 0x01382e97 in nsfclient.exe: 0xC00000FD: Stack overflow.

What should I do to be able to declare big arrays in Visual Studio?

like image 556
bit8bug Avatar asked Dec 29 '12 10:12

bit8bug


1 Answers

You should explicitly increase the stack size to be able to store bigger arrays on the stack. As far as I remember this is done using the /F option.

Another option would be to use dynamic arrays(allocated using malloc or new).

EDIT(thanks to Jefrrey Theobald): you will also have to increase the stack size in the linker, which is done using the /stack option. This option can also be set by right-click on the project->properties->linker->system and setting stack commit and stack reserve size. enter image description here

like image 150
Ivaylo Strandjev Avatar answered Nov 15 '22 05:11

Ivaylo Strandjev