What Can I Do To Reduce My Executable's Size (Delphi)?

前端 未结 15 1808
野趣味
野趣味 2020-11-30 07:36

I release a single executable (.EXE) for a desktop program using Delphi 2009. I have no external DLLs or resources that I need for the program to run.

I use two comp

相关标签:
15条回答
  • 2020-11-30 07:57

    I've done some tests to see the difference between D2007 and D2010, because we are upgrading to D2010. I've tested a medium sized management GUI application, with about 60 forms (grids with detail forms, frames, etc). We're using TMS components + Remobjects.

    D2007:
    "normal" compilation: 18.8mb
    with debug dcu's: 18.8mb (same size!)

    D2010
    normal: 23.9
    debug dcu's: 48.8mb (!)

    So using debug dcu's doubles our exe size...

    Test with our business service (no big dfm's):
    D2007: 12.3mb
    D2010: 17.1mb

    So yes, D2010 increases the exe (a bit), but this is not a problem for my customer.

    Edit: some information about compiled size:
    D2007:
    alt text
    D2010:
    alt text

    So an increase of code size, but a more than doubling of the data!

    0 讨论(0)
  • 2020-11-30 08:00

    Another way is to have a look to 'what unit increase the size ?'.

    To do this, I use the JCL 'Project Analyser IDE', integrated in the IDE with the JCL/JVCL installation, it show you all the units with their respective size. You can export it in text file. If you do it with the 2 environnements (D4 & D2009) you will have a lot of pertinent informations.

    0 讨论(0)
  • 2020-11-30 08:02

    Check format of your dfm-s. They must be in binary format if you want to make your exe smaller.

    0 讨论(0)
  • 2020-11-30 08:03

    Without seeing the actual settings that your "Release" build configuration uses explaining this increase in size requires a great deal of speculation.

    Beyond some perhaps unlikely factors resulting in a vast increase in the amount of code being "dragged in" even though it isn't used, that magnitude of increase would most easily be explained by the inclusion of debug information.

    I would check your compiler and linker settings for:

    • Debug Information (compiler setting)
    • TD32 info (linker)
    • Remote debug info (linker)

    Compare these settings in your Delphi 2009 project with the equivalents in Delphi 4.

    0 讨论(0)
  • 2020-11-30 08:05

    If you don't want to use an exe compressor then you should give StripReloc a try.

    0 讨论(0)
  • 2020-11-30 08:08

    Use "upx - compress or expand executable files" @ http://upx.sourceforge.net


    If you go to tools/configure tools, and set it up like this, you can compress the executable that you're working on easily via a menu item in the IDE.

    Configuration

    0 讨论(0)
提交回复
热议问题