11

If I compile my entire Delphi application to a single exe, that file will grow to 5MB, 10MB, maybe more. When is that too big? What are the issues with this? This is a commercial application, currently on Delphi XE.

I'm aware of the option to Build with Runtime Packages. That sounded like a good idea, but I see comments here noting that there are some issues and disadvantages.

Patrick Moloney
  • 642
  • 5
  • 14
  • I guessing you are packing resources like images, etc in your application? – Cyclonecode Nov 18 '11 at 14:26
  • There should be no limit to executable size, but of course loading a very big executable can take some time. We had Delphi executables > 100 MB working just fine. – Jens Mühlenhoff Nov 18 '11 at 14:41
  • Those sort of sizes are fine. If you get an executable size of around 1GB then you will begin to place pressure on your available address space under 32 bit Windows. – David Heffernan Nov 18 '11 at 14:45
  • Think of installation software, no problem with executable size inherently.. OTOH there might be f.i. a file filter driver which would like to scan the whole file before permitting access like AV software, or there might be users which would like to run the program from a network share, which would pull the whole file each time it is run.. Not answerable in my view.. – Sertac Akyuz Nov 18 '11 at 14:51
  • 2
    My top tips for reducing exe file size can be found here: http://stackoverflow.com/questions/7398580/reduce-exe-file/7398658#7398658 – David Heffernan Nov 18 '11 at 14:54
  • 1
    Thanks all. Some encouragement there. To clarify: there are no images. I'm satisified the app is the size it has to be. The question is about the size of the exe and vs packages. I assume if I built with packages, the AV software would scan the packages as well, so I don't see any saving there. Same with running from a network. – Patrick Moloney Nov 18 '11 at 21:15

3 Answers3

32

A Delphi application is never really too big.
However the larger the exe is, the harder it will be to redistribute the file.
Also if the executable is located on a network-disk start-up time may suffer.

A number of factors make the exe grow:

  • enabling debug info (will more or less double the exe size).
    enter image description here
    Disable the inclusion of debug info in the final exe (see screenshot above).
  • including bitmaps (in an imagelist or likewise component) will also grow the exe substantially.
  • including resources (using a custom *.res) file will grow the size.

I would advise against putting resources in a separate dll.
This will complicate your application, whilst not reducing the loading time and distribution issues.
Turning off debug info in production code is a must.
If you have a Delphi-2010 or newer you can choose to include images in the png format.
This will take up much less space than old-skool bitmaps.

As long as your app is below 30 MB I would not really worry overmuch about the file size though.

Strip RTTI info
David suggests stripping RTTI info (this will disable live-bindings and some other advanced stuff), see: Reduce exe file
According to David it saves about 30% in exe size.

Exe-size will only increase loading time
Far more important is the amount of data your application allocates as storage.
The amount of space you use (or waste) here will have a far greater impact on the performance of your application than the raw exe size.
Strategy or tools to find "non-leak" memory usage problems in Delphi?

A better way to optimize is to make sure you don't leak resources
How to activate ReportMemoryLeaksOnShutdown only in debug mode?
Windows API calls memory leak detection

Use smart datastructures and algorithms
It gets too general to really narrow it down here, but use algorithms with O(slowly increasing) over O(wasteful increase).
Big-O for Eight Year Olds?
And try and limit memory usage by only fetching the data that you need instead of all the data you might need but probably never will.
Delphi data structures
Etc etc.

Community
  • 1
  • 1
Johan
  • 74,508
  • 24
  • 191
  • 319
  • Note that the debug info that inflates the EXE size is the TD32 debug info controlled by the *Linker* options, as shown in the picture. The debug info controlled by the *Compiler* options has no effect on EXE size; it puts debug info in the DCU files, but that's not included in the EXE. – Rob Kennedy Nov 18 '11 at 15:25
  • 2
    Good writing, but most of it answering a non-asked question... I wonder how you've come up with the >30MB .. – Sertac Akyuz Nov 18 '11 at 15:59
  • @SertacAkyuz, Did a search through all the projects I've written. 30 MB was the maximum exe size :-). So if your app is 100MB I guess you must be doing something special to make it bloat like that. – Johan Nov 18 '11 at 16:06
  • I don't have debug information in there and I'm not really trying to optimize it, especially if it is good like it is. Not bad ideas if I get to tweaking it, but I'm not worried about that here. – Patrick Moloney Nov 18 '11 at 21:19
4

I don't know any issues with the exe-size of an application. I'm currently working at an application where the exe is around 60MB and there is no problem.
The only limitation I know are the limitation of the available memory. And an application with use of runtime-packages will consume more working memory because all runtime packages are load on application start. And the packages contains a lot of code wich is problably not used in your application.
I really like the idea of runtime-packages but I don't like the implementation in Delphi. One main disadvantage is that you have to ship your app with a bunch of packages wich makes it hard to maintain.

Michael
  • 858
  • 1
  • 5
  • 11
  • I have 100mb Executables that I have no problem with either. I think when EXE size exceeds 500 megs, it becomes inconvenient (but still possible) to download updates at will, when servicing software. That's about where the pain starts for me. But very subjective question really. The most painful problems with runtime packages means I would always avoid them even when size of executables became painful. I might use DLLs of my own, but not Delphi's BPL system. – Warren P Aug 20 '12 at 23:09
1

use RELEASE Build for reduce execute size , increase performance.also use runtime package for reduce exe file but use runtime package cause increase package(setup) file size.

MajidTaheri
  • 3,813
  • 6
  • 28
  • 46