Board index » delphi » Optimizing for executable size.

Optimizing for executable size.

Sorry if I have posted this to the wrong group, but I didn't see any groups
that would fit except for borland.public.delphi and there did not seem to be
any traffic in that group.

Using Delphi 2, you could go into project options and uncheck the debug and
symbol information and reduce the size of the resultant executable file.

In Delphi 4,  checking or unchecking those option seem to make no
difference.  The size of the executable is the same.  I wish to be able to
get my executable down as small as reasonably possible.  Can anyone give me
any tips on this?

An example application that I have uses several small forms with the usual
assortment of controls, check boxes, edit fields, etc on them.  It is not
using any database functionality.  It hase an open dialog box and a timer.
When compiled, this program is about 430K.  Does this seem large to anyone?
It seems that Delphi 4 programs compile larger.

Thanks in advance.

 

Re:Optimizing for executable size.


Quote
> The size of the executable is the same.

True, the only option which impacts .exe size is including TD32 information.

Quote
> I wish to be able to get my executable down as small as
> reasonably possible.

Okay, simply remove everything from it which is unnecessary. You could look
into using runtime packages.

Quote
> When compiled, this program is about 430K.

No, that seems about right.

Quote
> It seems that Delphi 4 programs compile larger.

That's right. The D4 VCL contains more code, to support more features. For
example, your controls all have anchors and constraints. The VCL has some
new code to implement this which gets linked into your application. Also D4
forms have more properties, which are stored as binary data in the .exe.

- Rick

Re:Optimizing for executable size.


Quote
Borland Newsgroups wrote in message <7jmgai$6h...@forums.borland.com>...

Please change your newsgroup identity.

Quote
>An example application that I have uses several small forms with the usual
>assortment of controls, check boxes, edit fields, etc on them.  It is not
>using any database functionality.  It hase an open dialog box and a timer.
>When compiled, this program is about 430K.  Does this seem large to anyone?
>It seems that Delphi 4 programs compile larger.

430K is pretty lean by today's standards! <g> (My current, not quite
finished, project is pushing 6meg - but there's over 300 forms!)

As Rick has already replied, new features in each version of Delphi
frequently result in a larger compiled size. That's the trade-off inherent
in using a product with such high-level design-time power.

The only thing that will really bloat your code unecessarily is if you drop
a component that pulls in units then remove the component - for example,
drop a TTable down and save or compile, then remove the TTable - your app
will now compile much (not all) initialization code and class methods from
database related units even though you aren't using them.

A way to clean this up is to "chop" the uses clause and let Delphi put back
what it needs, e.g:

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  MPlayer, StdCtrls, Grids, DBGrids, Db, DBTables;

I can edit the above so all that is left is:

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

When I save or compile (with no DB related components on my form) Delphi
puts back any extra units it still needs:

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  MPlayer, StdCtrls;

Note that you must preserve any units you have *manually* added to the uses
clause, Delphi cannot know to put these back.

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
"It is not true that the function of law is to regulate our consciences, our
ideas, our wills, our education, our opinions, our work, our trade, our
talents or our pleasures. The function of law is to protect the free
exercise of these rights." - Frederic Bastiat, 1850

Re:Optimizing for executable size.


Thanks for the suggestions!  Does my name show up any better now?

Richey / Delphi-Box <r.fell...@bigfoot.com> wrote in message
news:375fb60d.17854465@forums.borland.com...

Quote
> Hi "Mr Newsgroups" (can you change that?),

> you can find a number of tips concerning this question
> on my "Delphi FAQ" linked from my "Delphi Tips & Tricks" page
> (URL: see beyond).

> Regards,
> Richey

> On Wed, 9 Jun 1999 14:50:12 -0500, "Borland Newsgroups"
> <chrisd@ANTI*SPAMusti.com> wrote:

> >Sorry if I have posted this to the wrong group, but I didn't see any
groups
> >that would fit except for borland.public.delphi and there did not seem to
be
> >any traffic in that group.
> [..]
> _______________________________________________________________
> http://Inner-Smile.com, home of:
> INF-Tool - create *smaller* setup packages for your programs!
> Resource-Grabber - giving you 1000's of glyphs,images,icons,sounds..
> Richey's Delphi-Box - 1000+ links and answers for Delphi developers
> ..one of the best starting points for Delphi developers worldwide..

Re:Optimizing for executable size.


If your name is Chris then it does :)

Quote
Chris Dunaway wrote:

> Thanks for the suggestions!  Does my name show up any better now?

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
If there is somebody up there could they throw me down a line.  Just a
little helping hand just a little understanding.  Just some answers to the
questions that surround me now.  If there's somebody up there could
they throw me down a line.               (Fish)
--

Other Threads