Board index » delphi » How to optimize the size of DLL

How to optimize the size of DLL

I have written a DLL with Delphi but I think the size is too BIG
(about 600K). How can I optimize the size?

I am using Delphi 6

Thanks in advance.

 

Re:How to optimize the size of DLL


Quote
"Rex_chaos" <rex_ch...@21cn.com> wrote in message

news:f7a7417.0303290822.4832f80b@posting.google.com...

Quote
> I have written a DLL with Delphi but I think the size is too BIG
> (about 600K). How can I optimize the size?

You really shouldn't bother (A hell of a lot more trouble than it's worth,
and nobody cares about a few extra hundred kilobytes, unless it has to fit
onto a *snigger* floppy disk or something), but.... try not to use "Forms"
if you can - this is a big unit!

Cheers,
Nicholas SHerlock

Re:How to optimize the size of DLL


Quote
Rex_chaos wrote:
> I have written a DLL with Delphi but I think the size is too BIG
> (about 600K).

Have you tried compiling with run-time packages enabled?

Quote
> How can I optimize the size?

Remove the parts you don't need, of course. :)

--
Rob

Re:How to optimize the size of DLL


On 29 Mar 2003 08:22:07 -0800, rex_ch...@21cn.com (Rex_chaos) wrote:

Quote
>I have written a DLL with Delphi but I think the size is too BIG
>(about 600K). How can I optimize the size?

>I am using Delphi 6

>Thanks in advance.

Does the DLL (use/need) a Graphical Interface ?

If not then getting rid of the Forms unit will shrink the DLL
dramatically
- however other Units - the Dialogs unit in particular, use the Forms
unit so you need to use MessageBox instead of ShowMessage

Re:How to optimize the size of DLL


Quote
Rex_chaos wrote:
> I have written a DLL with Delphi but I think the size is too BIG
> (about 600K). How can I optimize the size?

> I am using Delphi 6

> Thanks in advance.

http://xcl.cjb.net

Re:How to optimize the size of DLL


Quote
"J French" <Bounce_It_je...@iss.u-net.com_.bin> wrote in message

news:3e86bec0.5457085@news.u-net.com...

Quote
> On 29 Mar 2003 08:22:07 -0800, rex_ch...@21cn.com (Rex_chaos) wrote:

> >I have written a DLL with Delphi but I think the size is too BIG
> >(about 600K). How can I optimize the size?

> >I am using Delphi 6

> >Thanks in advance.

> Does the DLL (use/need) a Graphical Interface ?

> If not then getting rid of the Forms unit will shrink the DLL
> dramatically
> - however other Units - the Dialogs unit in particular, use the Forms
> unit so you need to use MessageBox instead of ShowMessage

Will not the linker automatically delete any unit that is not used in the
DLL?
(Incidently, I am still on D5 and have no intention of upgrading)

Sven

Re:How to optimize the size of DLL


On Sun, 30 Mar 2003 21:23:53 +0200, "Sven Pran"

Quote
<no.dir...@mail.please> wrote:

<snip>

Quote

>Will not the linker automatically delete any unit that is not used in the
>DLL?
>(Incidently, I am still on D5 and have no intention of upgrading)

>Sven

The linker (or is it the compiler) seems amazingly smart, and not only
will it eliminate unused Units, but it will eliminate unused code
_within_ Units

However there are limitations to its smartness in some areas, I can't
remember the details, but it runs along the lines of :
    If it cannot be absolutely certain that something is not used
then...

Something like DirectoryExists pulls in FileCtrl which is about
another 16k

Regardless of that, a simple ShowMessage() will inflate your App by
300kb - because it uses Dialogs, which in turn uses Forms

I have found that the best trick is to prune the Uses Clause to
explicitly remove everything that is not required.

For a start it is good programming practise
- as it makes the code show what _is_ used

Also it makes one acutely aware of what is actually used.

The minimum size for a DLL or EXE is about 16k

BTW - I stick with D4 smething to do with a Borland salesman ringing
me up when I was just about to get D5 ...

Re:How to optimize the size of DLL


"J French" <Bounce_It_je...@iss.u-net.com_.bin> skrev i melding
news:3e880cf2.8262548@news.u-net.com...

Quote
> On Sun, 30 Mar 2003 21:23:53 +0200, "Sven Pran"
> <no.dir...@mail.please> wrote:

> <snip>

> >Will not the linker automatically delete any unit that is not used in the
> >DLL?
> >(Incidently, I am still on D5 and have no intention of upgrading)

> >Sven

> The linker (or is it the compiler) seems amazingly smart, and not only
> will it eliminate unused Units, but it will eliminate unused code
> _within_ Units

> However there are limitations to its smartness in some areas, I can't
> remember the details, but it runs along the lines of :
>     If it cannot be absolutely certain that something is not used
> then...

...like with all functionality thet has to do (explicitly or implicitly)
with setting of published properties...

--
Regards,

Bj?rge S?ther
bjorge@haha_itte.no
-------------------------------------
I'll not spend any money on American Software products
until armed forces are out if Iraq.

Re:How to optimize the size of DLL


Quote
"Rex_chaos" <rex_ch...@21cn.com> wrote in message

news:f7a7417.0303290822.4832f80b@posting.google.com...

Quote
> I have written a DLL with Delphi but I think the size is too BIG
> (about 600K). How can I optimize the size?

File size has absolutely no relationship to memory footprint. Even if (and
its a big if) the DLL has a 600KB footprint and is always RAM resident, one
is only looking at consuming 0.23% (or less) of the RAM on a modern machine.
Its just not worth the time or effort.

Re:How to optimize the size of DLL


On Mon, 31 Mar 2003 13:42:56 -0500, "Bruce Roberts"

Quote
<b...@bounceitattcanada.xnet> wrote:

>"Rex_chaos" <rex_ch...@21cn.com> wrote in message
>news:f7a7417.0303290822.4832f80b@posting.google.com...
>> I have written a DLL with Delphi but I think the size is too BIG
>> (about 600K). How can I optimize the size?

>File size has absolutely no relationship to memory footprint. Even if (and
>its a big if) the DLL has a 600KB footprint and is always RAM resident, one
>is only looking at consuming 0.23% (or less) of the RAM on a modern machine.
>Its just not worth the time or effort.

I am not sure that I totally agree with that
- there is a lot to be said for pruning the 'uses' clause
- it means that it lists 'explicit' dependancies
- rather than 'anything that the unit might possibly use'

Also a 600k DLL does strike me as rather large ...

Re:How to optimize the size of DLL


Quote
"J French" <Bounce_It_je...@iss.u-net.com_.bin> wrote in message news:3e8954e9.1914635@news.u-net.com...

> Also a 600k DLL does strike me as rather large ...

It does sound large but of course it depends on what it is doing.
I have a Delphi 6 dll that is 20K but it is just a shared memory
ipc library with only WIN32 API calls an no user interface.

Re:How to optimize the size of DLL


On Thu, 03 Apr 2003 20:50:55 GMT, "Kevin Gale"

Quote
<KevinRemoveThisSt...@House-in-the-Woods.net> wrote:

>"J French" <Bounce_It_je...@iss.u-net.com_.bin> wrote in message news:3e8954e9.1914635@news.u-net.com...

>> Also a 600k DLL does strike me as rather large ...

>It does sound large but of course it depends on what it is doing.
>I have a Delphi 6 dll that is 20K but it is just a shared memory
>ipc library with only WIN32 API calls an no user interface.

I reckon that a 600k DLL probably contains quite a lot of Graphical
interface

My DLLs (without GUI) seldom rise above the 100kb mark, even when they
contain some fairly hefty code.

Other Threads