Solved

Very big Dll - how to make it smaller

Posted on 2001-06-17
17
321 Views
Last Modified: 2010-04-06
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 ......
0
Comment
Question by:TomazB
  • 3
  • 3
  • 3
  • +6
17 Comments
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6199806
Try building your dll with runtime packages.

Jo
0
 
LVL 17

Expert Comment

by:inthe
ID: 6199940
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.
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6200174
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.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 5

Expert Comment

by:Gwena
ID: 6200209
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
0
 

Author Comment

by:TomazB
ID: 6200265
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?
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6200273
The dll's will decompress automatically... no trouble at all
0
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6200351
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
0
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6200397
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 6200536
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 6200582
www.aspack.com

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

Shane Holmes
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 6200584
www.aspack.com

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

Shane Holmes
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6201001
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
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 6201710
Compile your dll with the debuging options turned off!
0
 

Expert Comment

by:Aum
ID: 6201799
"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
0
 
LVL 5

Accepted Solution

by:
Gwena earned 50 total points
ID: 6203994
"Is there any other way to make form (with some controls) than using VCL Foms?"

Try looking here   http://mercury.spaceports.com/~bonanzas/kol/

If you use the stuff here instead of delphi's vcl code you can get exe's
as small as 14kb with forms ... and that's with D4 or D5 :-)
0
 

Author Comment

by:TomazB
ID: 6204128
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?
0
 

Author Comment

by:TomazB
ID: 6291061
Well, a lot of work was here but a little progress.
Anyway Gwena gave me the most info to work on.
Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question