delorie.com/djgpp/faq/memory/stack.html | search |
How much stack space do I have in my program?
Under non-DPMI environments, your stack will dynamically expand as required, so you have virtually unlimited stack. Unfortunately, this can't be done under DPMI, so there you get a fixed-size stack which defaults to 256K. If that's not enough, you can change it with stubedit program (change the parameter "Minimum amount of stack space"), or by setting the global variable _stklen in your program. Example:
extern unsigned _stklen = 1048576;Setting _stklen makes sure your program always works, but wastes memory, since the 256K stack originally allocated must be discarded. The best bet is to do both - setting _stklen in your program will ensure it works, but also using stubedit to set a slightly (by a few KB) larger amount than the value of _stklen, will ensure the original stack won't have to be reallocated, and you will save the wasted memory.
prev next webmaster | delorie software privacy |
Copyright © 1995 | Updated Feb 1995 |