Link to home
Start Free TrialLog in
Avatar of TomazB
TomazBFlag for Slovenia

asked on

Very big Dll - how to make it smaller

Is there a way to make my Dll smaller? I use a lot of units in my dll:

  ShareMem,
  SysUtils,
  Classes,
  Windows,
  Forms,
  Dialogs,
  DB,
  ExtCtrls

and I know that program needs them. But I don't know how Delphi copiles that units. My dll reached size of 570k.
Does Delphi puts in compiled dll just the necessary kode from units or whole units? If last, is there a way to minimize size of compiled file? (mybe some switches or so) I think that a little form which I need in dll shouldn't make so big file or ......
Avatar of nnbbb09
nnbbb09

Try building your dll with runtime packages.

Jo
also look at what functions your actually using from the units in the dll and if your only using one or two functions form a particular unit you may be able to just declare it in your dll instead.
As soon as the VCL Forms unit is included, applications and DLLs get bloated up very much. That's just the way it is; using packages will make smaller DLL's but require to distribute additional files which will make a total size even larger than the original (non-package) DLL was.
You can compress some dll's with the free UPX compressor
I compressed the xaudio.dll from 254976 down to  113152
using UPX --best xaudio.dll

http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
Avatar of TomazB

ASKER

That compile with runtime packages - how to do that?
Is there any other way to make form (with some controls) than using VCL Foms?
This compress.....I assume that dlls must be decompressed before use in the program. Is this somehow automatic or must I do that within my program and then use dll of normal size from the disc?
The dll's will decompress automatically... no trouble at all
To use runtime package go to Project | Options and select the Packages tab and then check the Build With Runtime Packages checkbox. Then rebuild your dll.
When distributing your dll to other machines you will also need to distribute any VCL packages that it has used. To get this list of packages go to Project | Project Information and it should give you a complete list (you may need to recompile first).

Jo
To use runtime package go to Project | Options and select the Packages tab and then check the Build With Runtime Packages checkbox. Then rebuild your dll.
When distributing your dll to other machines you will also need to distribute any VCL packages that it has used. To get this list of packages go to Project | Project Information and it should give you a complete list (you may need to recompile first).

Jo
The best tool I have encountered on the market is ASPack.

http://www.aspack.com/

Try it, you will be pleased. This will cut your size from 6ooK to about 300K or less, depeding on the types of resources added to the DLL

Shane
www.aspack.com

This will compress it to half the size, with no loss of functionality.

Shane Holmes
www.aspack.com

This will compress it to half the size, with no loss of functionality.

Shane Holmes
Anyway, if your DLL will be loaded by multiple applications, packing the DLL might not seem to be wise:

http://www.jrsoftware.org/striprlc.htm
Compile your dll with the debuging options turned off!
"Is there any other way to make form (with some controls) than using VCL Foms?"

You can use the Windows APIs (CreateWindow, etc.). You can still desing your forms in Delphi's IDE, and then read the .dfm file to get the required properties, like Top, Left, etc. Not a minor task, inded.

Or you can try using XCL, which wraps this for you:

http://members.nbci.com/_XOOM/mr_bonanzas/xcl/index.htm
ASKER CERTIFIED SOLUTION
Avatar of Gwena
Gwena

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TomazB

ASKER

Well since my app uses instances of objects in a few dlls this problem with relocating realy exists. Also a lot of memory is used since three apps uses them. Sims that Dragon is right about dangers with compresss.
This stuff with runtime packages is also tricky. Avon is right. All together is even larger than dll allone. Isn't there a way to tell Delphi to just compile what is needed?
Avatar of TomazB

ASKER

Well, a lot of work was here but a little progress.
Anyway Gwena gave me the most info to work on.
Thanks