简体   繁体   English

Delphi XE8控制台应用程序代码大小

[英]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. 它只有80行代码,没有单位,全部在主程序文件中完成。 It was originally compiled in D2007 and compiled exe size is 84kB. 它最初是在D2007中编译的,编译后的exe大小为84kB。

I am trying to compile the file in XE8 32 bit and its compiled size is 1MB. 我正在尝试使用XE8 32位编译文件,其编译大小为1MB。

I expect a bit of an increase with new versions, but 12 times bigger is exceptionally bad by any standard. 我预计新版本会有所增加,但按任何标准,将其放大12倍都是非常糟糕的。

It been compiled in release mode with all the debugging options turned off. 它是在发布模式下编译的,所有调试选项都已关闭。

The uses clause includes only "registry,Windows,dateutils,SysUtils". Uses子句仅包括“ 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 . 您正在使用的System.Win.Registry使用的System.Classes使用System.RTTI

(following sizes are for XE4, but XE8 should not be far off) (以下尺寸适用于XE4,但XE8应该相距不远)

Empty console app with only System.SysUtils in uses is 122 KB in size. 仅使用System.SysUtils空控制台应用程序的大小为122 KB。 Add System.RTTI and you will end up with 962 KB. 添加System.RTTI ,您将最终获得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. 解决方法是取出用过的RTL单元,将它们复制到您的项目文件夹中,并向其中添加{$WEAKLINKRTTI ON}{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

For instance doing the above to System.RTTI and System.Classes will reduce console size to 417 KB. 例如,对System.RTTISystem.Classes执行上述操作会将控制台大小减小到417 KB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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