Just wondering what the limits on stack size are in Win32. Is there anyway of increasing them and how? I was trying to declare a large local array. It compiled fine, but crashed when executed. A quick fix is to declare a global array, but I'm asking strictly out of curiosity.



Wndproc...
local pt[1000]:POINT
local...
Posted on 2001-08-05 01:16:27 by Jafo
Jafo,

The stack size in MASM is adjustable in the link options, just set the stack reserve and commit sizes and you will solve the problem.

Regards,

hutch@pbq.com.au
Posted on 2001-08-05 01:22:47 by hutch--
The problem you have is that windows allocated memory to allow the stack to grow in an ineffective mecanism.

It works by allocating memory as your program accesses the page in memory after the last page in the use by the stack. Effectivly this forms a guard page to let windows know when it needs to allocate more memory to allow the stack to grow.

The problem occurs when you access memory beyond the guard page (4096 bytes past the current stack limit) which is technicaly still inside the stack, but windows doesn't recognise this and causes and exception
Posted on 2001-08-05 03:59:07 by huh
What huh says is correct. This means that if you have *large* amounts
of data on the stack, you cannot access it "randomly". You must
either access all the data linearly, or do a "pretouch" (reading/writing
every 4096th byte).
Posted on 2001-08-05 13:17:43 by f0dder