Solved

Very big Dll - how to make it smaller

Posted on 2001-06-17
17
317 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
Comment Utility
Try building your dll with runtime packages.

Jo
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
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
Comment Utility
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
 
LVL 5

Expert Comment

by:Gwena
Comment Utility
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
Comment Utility
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
Comment Utility
The dll's will decompress automatically... no trouble at all
0
 
LVL 3

Expert Comment

by:nnbbb09
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Compile your dll with the debuging options turned off!
0
 

Expert Comment

by:Aum
Comment Utility
"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
Comment Utility
"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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now