Delphi tip: reduce exe size
If you've been a Delphi user since its early days, you may remember that the smallest applications were a few hundreds of kilobytes in size. (Visual Basic adepts would laugh at it and say their programs were only a few tens of kilobytes, but they forgot to mention that they needed a megabyte+ of a runtime library, while Delphi programs were standalone.) Anyway, with new versions the program size increased only little, until the release of Delphi XE3 by Embarcadero. Let's look at the filesize for a "hello world" program: a button on the main form whose onclick procedure looks like this:
procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage('Hello world'); end;
That's it. Below is a graph with the exe sizes for different Delphi versions.
The XE3 version is 36 times the size of the Delphi 4 version! Many users find this rightly outrageous. The good news is that there's a way to reduce it a bit (though the file will remain huge).
By default a Delphi program is compiled in the debug configuration, which means a lot of information is included which you don't need for the release version. Changing to the release configuration will throw out all of this ballast. Newcomers often seem to think you have to change something in Options... under the Project menu. Well, there's indeed a target selector, where you can choose between Debug or Release. But that's only to show the options for either target, not for selecting the target itself.
You select the build configuration in the Project Manager, at the top right of the IDE.
Note that you have to double-click (not just click) Release to make it the active target; the active target will show bold.
The filesize for the Release version is still 2 230 kB, but down from 10 718 kB it's a saving of almost 80%. This is still 7.5 times as large as the Delphi 4 version, though, so it looks like the programmers at Embarcadero still have to work on that.