Tutorial :What can influence Delphi executable size?



Question:

I have the very same delphi version, bpls, components, everything. And yet in three machines the resulting executables are different in size. What else can influence in the size of the exe?

In my machine I get this size (Vista 6.0.6001):

4.547.584 bytes  

In my colleague's machine, he gets (XP 5.1.2600 SP3):

4.530.688 bytes  

In a third colleage, he gets: (XP 5.1.2600 SP2)

4.527.104 bytes  

Does the OS version influence in the compiled exe size?


Solution:1

It would seem that it is configuration differences, or if maybe you have different versions of components installed between the three machines. I would suggest creating a blank form and trying it on all 3 after you verify that the build settings are the same. If that is the same then add some 3rd party components until you find the one that is different.

Additionally you may have a different version of Delphi (major or minor/update version).


Solution:2

The differences almost certainly come from different compiler settings between the machines. For instance, turning Range Checking on or off will slightly alter the resulting size of the executable.

One of the nice things about the more recent versions of Delphi is the use of MSBuild, which can easily ensure that the settings for any given build are the same.


Solution:3

Hmmm...

SizeOf(XPSP2.exe) < SizeOf(XPSP3.exe) < SizeOf(Vista.exe)

Conclusion:

The later the version of Windows, the more "filler" is randomly inserted to add credibility. If it takes more space then it must be more powerful, and it was probably coded by the best engineers in the world! :-) (sorry - I've been working at Microsoft for too long!)


Solution:4

With Delphi/BCB these are a few factors that can influence size:

Your Build Configuration: Release Mode does not link in the debug section into the EXE (by default) so is smaller. also you may get a boost from code optimization.

Linking with Dynamic RTL: If enabled you EXE will be smaller but you will require the external libraries to be available.

Building with Runtime Packages: If enabled, you dynamically link to the runtime packages you use instead of linking them directly into your EXE. This can result in the largest size differences.

Their are other factors but the above tends to be the main ones I come across.


Solution:5

IIRC, re-compiles after making minor changes may also leave cruft laying around - one fo the side effects of the smart compiler, I guess :}


Solution:6

Actually, it's a issue that's been around for quite some time. See

CodeGear Quality Control

Borland Delphi newsgroups

Recent discussion of this on Delphi newsgroups (http view).

It has absolutely nothing to do with differences in component installs or anything like that; in fact, the last reference mentions something to do with timestamps that are inserted into the application on each compile/build. Also, if you're doing a build and are including version info, and have the build number set to autoincrement, this will cause binary differences as well.


Solution:7

Actually it's much more interesting than than.

Even re-building the same application on the same machine, several times in succession, making absolutely NO changes to the configuration whatsoever in between compiles, produces executables of slightly different sizes. I built a particular project 10 times and obtained 10 (!) different executable sizes - a different size every time!

I've noticed that the phenomenon only occurs on projects of sufficient size/complexity, though.

If you do this on a relatively simple project, the executable will be the same size, even though there will still be internal differences (if you do a binary compare). I don't have the time to investigate this right now, but I am mildly curious.

Notice that merely doing a compile, i.e. effectively just re-linking the application, does not change the size of the resulting executable, but it does change its content (binary files generated are not identical).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »