Stack Space - Does it vary from PC to PC

Blitz3D Forums/Blitz3D Programming/Stack Space - Does it vary from PC to PC

Matty(Posted 2006) [#1]
On occasion I need to write recursive routines and although those I've used so far have not run out of stack space I know that it is a possibility. Do different PCs have a different amount of stack space? Is it measureable? If so, how is it measured?


Damien Sturdy(Posted 2006) [#2]
It's down to the EXE and not the target machine :) So i'd imagine it was global.


Matty(Posted 2006) [#3]
If it is down to the exe then does that mean that two different PCs would run out of stack space at the same time when the same code is run?


GfK(Posted 2006) [#4]
If it is down to the exe then does that mean that two different PCs would run out of stack space at the same time when the same code is run?
I just did a quick test in Blitz 3D - I got a function to call itself repeatededly more than 43,000 times before the program crashed. Strangely it didn't produce a stack overflow error as would be expected - it just stopped running. Debug is on.
Global count = 0
Recursive()
Function Recursive()
	count = count + 1
        Print count ;Added this because the code isn't producing a stack overflow error
	Recursive()
End Function



Damien Sturdy(Posted 2006) [#5]
heh, Yeah, the exe will crash at the same time on each PC.

GFK, Unusual. in release, blitz normally just closes. Perhaps an update broke the behaveor of Debug?


boomboom(Posted 2006) [#6]
With Debug on, I got the same as GfK. With Debug off, it got to about 51000. I assume thats due to the debug taking some of the stack.


Matty(Posted 2006) [#7]
Thanks, all very helpful.


Rroff(Posted 2006) [#8]
I get the same as said above, about 43K with debug on and about 51K without, no error or crash the program just exits.


SebHoll(Posted 2006) [#9]
What actually is "stack space"? Is it how many times you can call a function from within itself?


big10p(Posted 2006) [#10]
When you call a function, the return address and parameters are placed on the stack. It's just a temporary storage space. A stack is also known as a LIFO structure (Last In, First Out).


Chi3f Stadi(Posted 2006) [#11]
Information about Stacksize seems to be in the executeables under Windows.

To increase or decrease the stacksize you can use "EDITBIN.EXE" and set a new size.

EDITBIN.EXE can be downloaded with the MASM32 Package.


Picklesworth(Posted 2006) [#12]
Would this changed stack size be per executable, or at a global scale?

If it's global, that would be a fantastic way to destroy one's Windows installation...


Damien Sturdy(Posted 2006) [#13]
Per executable.

:p