View Full Version : What fgures into my stack size? heap?

02-06-2002, 05:12 PM
How do I figure out how large my programs stack is? What do I add up for memory, what else goes in, etc.... What about the heap? I need this to specify the sizes of these in my Module Definition for a Windows program.

02-07-2002, 03:46 AM
Your programs stack size is not really fixed. When you call a function, you use more stack space, if that function calls a function, more, and so on. Recursive functions can grow a large stack. On most OS's, Windows included, there is a minimum stack size but it dynamically grows to suit.

Heap depends on how much dynamic memory you have allocated. Windows implements a flat 32 bit addressing scheme. Your program is thus limited to 4G. Your heap and stack are in there, along with your code and a few other things. Memory is paged into and out of memory from the pagefile as necessary, (thus you do not need 4G of RAM to run a 4G program, just a big pagefile).

You should not need this information up front to write a Windows program.