如何实现更小的可执行文件大小? [英] How to achieve smaller size of the executable?

查看:269
本文介绍了如何实现更小的可执行文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我经过长时间的停顿回到德尔福,写了一个相当简单的实用程序,我的客户要求支持一个较旧的版本...

Very recently I have come back to Delphi after a long pause and written a rather straightforward utility app my client requested to support an older release...

我知道这些天的大小没有多大关系,但它让我很奇怪,单位单位的应用程序,编译时,相当于1'084'416 b可执行文件。

I know these days the size does not matter much, but it struck me as odd that the one-unit application, when compiled, amounted to 1'084'416 b executable. The one and only .pas unit I wrote is some 20.8k large, mostly because of the richness of the gui.

使用

The uses clause is as follows:

uses
  Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, strutils,
  Dialogs, ADODB, DB, DBGrids, ExtCtrls, DBCtrls, StdCtrls, Grids, Menus,
  Buttons;

我想知道是否有任何方法可以将应用程序的大小减少到300-400k或更少?

I wonder if there's any way I could reduce the size of the application to 300-400k or less?

推荐答案


  1. Did you do a debug or release build? (Make it release for smaller size, make sure optimization is on, debug information turned off)

您是否关闭了RTII(delphi 2010)(如果不需要)? (较小的EXE大小。)

Did you turn off RTII (delphi 2010) if not needed? (Smaller EXE sizes.)

您的主机使用子句中的单位数,不是猜测EXE大小的好方法。以这种方式思考:VCL本身是一个大量的代码,数据库层另一个,你写的东西可能是EXE大小的很小百分比。

Number of units in your uses clause of your main unit, is not a good way to guess EXE size. Think of it this way: The VCL itself is one large amount of code, the Database Layer another, and the stuff you write is probably a very small percentage of the EXE size.

要了解您的可执行文件大小,请尝试JCL项目分析器,或读取打开映射选项时生成的MAP文件。

To understand your executable size, try the JCL Project Analyzer, or read the MAP file that is produced when you turn on the Map option. This will tell you exactly what is inside your executable file.

这会因为各种原因而愚蠢,但你可以例如,使用Delphi 7获取较小的可执行文件。最后,当我做一个应用程序,我想让它更小,我看看需要多少时间,以及多少努力重建一切(如用一个vcl替代),然后我对自己说,忘了

It would be silly for various reasons, but you could get a smaller executable by using Delphi 7, for example. In the end when I make an application and I want to make it smaller, I look at how much time it would take, and how much effort to rebuild everything (such as with a vcl alternative) and I then say to myself, forget about it.

这篇关于如何实现更小的可执行文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆