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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executable size

Status
Not open for further replies.

mastermagrath

Technical User
May 21, 2004
28
US
Sorry folks for asking more newbie questions but i'm playing around with my compiler to understand it better and a few things don't figure.
Under windows the size of my executable will go up and down as i add or remove functions from my project.
However if i start defining e.g. some extra floats etc in my main function and recompile, the executable remains the same size?? Can anyone explain this as i thought the compiler would set aside memopry for each variable you define(incidentally i'm looking at the size in bytes not kbytes)

Thanks in advance
 
A few extra variables won't change the size of the executable: it just allocates them on the stack or in the data segment.

A few extra constants will.
 
The reason that constants (or global variables) increase in size is that they are put into the .data segment, which is in the main executable.

Variables on stack will not increase the size of the executable on disk, but will use stack memory, like global variables.

In Low-level code, the stack is only a memory location and there is a pointer which points at the top of the stack. This pointer decreases as the stack grows. The reason that stack variables don't increase the exe size on disk is that the allocated storage does not matter for the executable size, because the compiler simply subtracts the number of bytes your variables take from the stack pointer.

It does not matter how much you subtract from this stack pointer; you will still get the same executable size.

Sorry if you didn't understand it, but I can't find a way to explain it better.
 
As usually, exe file size increments with step == 4K. So you may add some new functions (codes), constants, initialized static variables etc and have the same exe size. Then you add a short line and get +4K exe size...

With static library linkage you may add (into exe) lots of additional RTL code if you call additional library functions...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top