Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stack question... 2

Status
Not open for further replies.

LiquidBinary

Programmer
Jul 27, 2001
148
US
Every program requires it's own stack space right? When a program is first fired up, how big is it's stack space? Is it big enough to accomadate every stack frame in the code? Or does the program's stack grow to adjust to any new stack frame placed on the stack? Mike L.G.
mlg400@blazemail.com
 
Under W9x etc. I'm not quite sure how the stack is managed, with NT/W2K a certain amount of storage is reserved, by default 1MB (a relatively cheap operation)and a single page is actually allocated. The allocated page is followed by a "guard page" which cannot be accessed. When the stack size reaches the point that the guard page is accessed, a memory access exception occurs, and Windows intercepts this and allocates new stack space from the previously reserved area. The stack therefore grows dynamically until the end of the reserved area is reached. The default reserved size and allocated size can be changed by means of entries in a .DEF file, or by link parameters. For full details you can refer to Jeffrey Richter's "Advanced Windows". :) Hope that this helped! ;-)
 
Thanks for the great feedback Dave!!! Mike L.G.
mlg400@blazemail.com
 
--LiquidBinary
If you have QuickView installed and running you can view information about any executable the has the PE header format like: the initial and rezerved stack, heap, base address and many other information for your executable.

If you don't you can make a small console executable to read this information from the executable file you specify. You will have to use ImageLoad/ImageUnload API functions from imagehlp.h and imagehlp.lib. It works fast and relyable.

Some information about your executable can give you also the Dependency Walker that comes with VisualStudio.

HTH,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Thanks for the feedback Ionel!!! Latley I have been extremely interested in understanding the low-level workings of my code. You guys have really enlightened me. Thanks again. Mike L.G.
mlg400@blazemail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top