简体   繁体   中英

Delphi XE8 Console App code size

I have a little console app that I use in an installer to set registry settings and date stuff. Its only 80 lines of code, no units, all done in the main program file. It was originally compiled in D2007 and compiled exe size is 84kB.

I am trying to compile the file in XE8 32 bit and its compiled size is 1MB.

I expect a bit of an increase with new versions, but 12 times bigger is exceptionally bad by any standard.

It been compiled in release mode with all the debugging options turned off.

The uses clause includes only "registry,Windows,dateutils,SysUtils".

Is this normal or have I missed some other settings to turn off?

Problem is in your uses list. You are using System.Win.Registry that uses System.Classes that uses System.RTTI .

(following sizes are for XE4, but XE8 should not be far off)

Empty console app with only System.SysUtils in uses is 122 KB in size. Add System.RTTI and you will end up with 962 KB.

Solution is to take out used RTL units, copy them to your project folder and add {$WEAKLINKRTTI ON} and {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} to them.

For instance doing the above to System.RTTI and System.Classes will reduce console size to 417 KB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM