Delphi XE3 EXE file size 25 times larger than Dephi 7
Asked Answered
E

4

15

As a test I decided to create a simple "Hello world" app in Delphi using Delphi 4, 5, 6, 7, 2005, 2010 and XE3. The app is nothing more than a TForm, a TButton with an OnClick event that calls ShowMessage('Hello world').

Below are the results of each final EXE with debugging turned off:

File sizes of EXEs

Can someone explain why the XE3 version is 26 times larger than the average of the previous versions of Delphi?

Here are my project settings for XE3:

Settings 1

Settings 2

Expectation answered 4/5, 2013 at 18:42 Comment(6)
Take a look at the comments and answer to this question: #9168438Cailean
Cannot repro. For me it is 2230KB.Erythrocyte
@DaleM Maybe true, but there's a HUGE difference between 2x the size and 25 times the size. Plus that's 2010. This is XE3.Fenton
me wants a tag [size-matters]!Canzonet
How many attempts have you made at this? Surely there's something you did in XE3 which you you didn't do in the others. Try creating another new dummy application. Maybe you're including some other units which you forgot to remove.Fenton
I suggest installing JCL map package ("project information" menu item)Canzonet
H
10

You may have done a only a compile after changing to 'Release' configuration. Try to do a rebuild (not recompile). This will truly activate the Release configuration on the executable, and perhaps a smaller file size.

For me (Delphi XE2), the size reported by Windows for the same app (Release configuration) is:

1.52 MB (1,600,512 bytes)

Holdback answered 4/5, 2013 at 18:45 Comment(2)
Delphi really generates huge executable files. I don't believe that RTTI is the reason. Compiler is inefficient on the subject same like it is at optimization. Simply Embarcadero doesn't care for the executable size. But it is a big problem especially for Mobile Applications which have limited resources.Athamas
@BasePointer RTTI means that the smart linker cannot strip unused functions. There is no single reason for the large executables, but new style RTTI is probably the biggest factor. On the desktop, the large size of an executable doesn't matter at runtime. It's only an issue for downloading installers.Erythrocyte
E
6

I figured out the problem. Chalk this up to the fact that I use Delphi 7 99% of the time when I develop, and XE3 is new to me. Even though I had chosen "Release" under the project options and made my tweaks there, it turns out that simply choosing "Release" there does not put the project into Release mode.

This isn't enough

Who would have thought that I also had to use the Project Manager panel and double click on the "Release" item in order to put the project into Release mode?

Solution

If anyone is curious, the final EXE is now 2,229 KB, which is only 5 times the size of the EXEs prior to Delphi 2010.

Expectation answered 4/5, 2013 at 20:2 Comment(6)
You know you can create as many configs there as you want? Let's say you have 20 different build configurations, and you're working on one of them. When you go to debug that one configuration, do you really want all 20 of them to be compiled? I mean, that would take 20 times as long. So in other words, yes, you need to change this here.Fenton
No, I did not know that. Perhaps Embarcadero needs a "welcome to the 21st century" quick-start whitepaper for all those coders using Delphi 7 and below, explaining what's new and important. :-)Expectation
Please do accept @Steve's answer. And the IDE is behaving just as is to be expected. It's perfectly reasonably that the settings for the different configuration options can be edited without changing the active configuration.Erythrocyte
Still 5 times the size? Ugh!Celin
If you really want to compile more than the active build configuration at once, you can use Build Groups for that. See: docwiki.embarcadero.com/RADStudio/XE3/en/Build_GroupsMatz
It's not that you also have to change it in the project manager; you only have to change it there. The target in project Options is just there to show you the options for that target, it doesn't matter if that's your actual target.Klansman
R
2

Just put these lines in your .dpr file, it reduces exe size by 20%

uses Windows,

{$O+} {$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}

Religieux answered 21/4, 2017 at 5:28 Comment(3)
but do it only for exe file!Reseau
Delphi 10.1 Berlin, [dcc32 Error] FinalFrontier.dpr(4): E2003 Undeclared identifier: 'IMAGE_FILE_RELOCS_STRIPPED'Fenton
@JerryDodge adding uses Windows fixes that error message.Actinozoan
T
0

Well .. there are many things that explain the difference between the old delphi release and the new .. the important thing is the support of unicode (D2009 .. DXE4),all chars in unicode alloc 2 bytes (in D1,D2,D3,D7,...they only alloc one byte)

Tooth answered 4/5, 2013 at 19:6 Comment(3)
No, that's not really the big issue. There's always more code in each release. But the big change is new style RTTI which greatly increases the size of the VCL units. But in this case it's a simple debug vs release.Erythrocyte
'The important thing'? Really? But this would only explain a change by a factor of no more than 2.Suzette
David: in my experience exe size doubled most significantly going from 2007->2009, probably because rewrite of RTL due to unicode. D2010 increased again due to RTTI, but if you turn that mostly off, it is less than the 2007->2009 hump.Lindberg

© 2022 - 2024 — McMap. All rights reserved.