Solved

Application size

Posted on 2000-04-23
27
166 Views
Last Modified: 2010-04-04
Why are my Delphi applications always so big, and what can I do to reduce their size??
0
Comment
Question by:nrico
  • 9
  • 6
  • 3
  • +5
27 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2741670
there are a few things you could do:

1. Turn off "Compile with Debug info".
   This will cut down the size considerably.

2. Consider compiling resources into
   companion libraries. If you have a lot of bitmaps or icons in your project, use a resource DLL. This way the EXE is that much smaller, plus it could possibly run faster, since you need only load that DLL when it is needed.

3. Check for repitive code and compartmentalize it. If you have a routine that does something that another routine is doing (for example buttonclick events), you could make a single routine which takes parameters.

For example:
OLD WAY:
Procedure Button1Click(sender:Tobject)
begin
  Showmessage(Button1.name)
end;

Procedure Button2lick(sender:Tobject)
begin
  Showmessage(Button2.name)
end;

NEW WAY:
Procedure NewButtonClick(Sender:Tobject)
begin
  ShowMessage((Sender as TButton).Name)  

* this is a simplistic example, but you get the point.



Good luck!!

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2741673
how big ?

you can exclude the debuginfo (if not done) at
Project|Options|Linker|EXE and DLL Options
turn all off (integrated debugging works also)

this will make the exe ~75% smaller
0
 
LVL 1

Author Comment

by:nrico
ID: 2741689
Does it? I tried turning of debug information but it didn't give me any size gain.
And I'm talking about 300+ Kb for a program that does, well, nothing yet.
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2741696
if you have any forms whatsoever, you are not going to get an application for less than that. The forms unit adds a miniumn of ~200k, linking adds the rest.
0
 
LVL 1

Author Comment

by:nrico
ID: 2741700
DrDelphi --
  Yes, of course I know those optizations. But my CGI app doesn't contain resources or much procedures, and I want it as small as possible.
0
 
LVL 1

Author Comment

by:nrico
ID: 2741703
I don't have any forms (just a few TPageProducers), and I'm not willing to settle for that size.
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2741704
if it is a CGI application, you proabably aren't using any forms at all.
make sure that Forms isn't in the uses section.
0
 
LVL 1

Author Comment

by:nrico
ID: 2741714
The unit 'Forms' is NOT in my uses clause. I am including these units:

cgidisc.dpr:
Uses
  HTTPApp,
  CGIApp,
  main in 'main.pas';

main.pas
Uses
  Windows, Messages, SysUtils, Classes, HTTPApp;

Which should I remove?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2741723
how big ?

you can exclude the debuginfo (if not done) at
Project|Options|Linker|EXE and DLL Options
turn all off (integrated debugging works also)

this will make the exe ~75% smaller
0
 
LVL 1

Author Comment

by:nrico
ID: 2741727
Yes, kretzschmar (nice picture BTW ;-), pressing F5 is potentially dangerous for the question... :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2741731
oops, posted twice :-))

the httpapp-unit uses forms
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2741755
hi nrico

btw. you've also this q posted twice :-))
btw2. thanks for the compliment :-)

well, depending on your code, i guess,
it would be hard to get rid of the forms-unit,
because the cgiapp-unit ->uses httpapp-unit ->uses forms-unit

meikl
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 75 total points
ID: 2741818
another idea,

did you thought about to use upx

look at
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html

meikl
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:DValery
ID: 2742753
I'd recommend to look here:

http://mercury.spaceports.com/~bonanzas/xcl_main_info.htm

I's the fine library for small Delphi projects.
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2742960
What is the purpose of Debug info

Motaz
0
 

Expert Comment

by:Zdhanko
ID: 2743097
Add {$APPTYPE CONSOLE} directive to
produce console application and
remove directive {$R *.RES} from
project file and use project file
as main programm.
remove from project file strings with "Application" word
begin
{your code here}
Application.Initialize;
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end;
Doing so size of EXE may be 64KB.
You can also reduce heap stack size.

0
 

Expert Comment

by:Zdhanko
ID: 2743109
{file spray.dpr}
program spray;
{$APPTYPE CONSOLE}
uses  SysUtils,Classes,mxarrays,inifiles;
 ...
procedure ReadSprayIni;
begin
....
end;

begin
 ReadSprayIni;
end.
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2743243
Zdhanko Didn't you think that he may need Application object? because he uses TWebModule, didn't need intialization?

Sorry Nrico, but I have the same problem, I'm write CGI server side applications using Delphi.

Motaz
0
 

Expert Comment

by:Zdhanko
ID: 2743346
My solutiion not for such a program,
but for another types works good.
0
 
LVL 1

Author Comment

by:nrico
ID: 2744614
kretzschmar --
  I know I posted the question twice (three times to be correct, but I've already deleted one). It seems that when I press F5, my last post is repeated...
I don't like the UPX idea, I want to keep my executable as "clean" as possible. Plus, it seems UPX has to decompress my EXE, which means it would take extra time and I want to minimize running time, with my eye on the server-timeout.

DValery --
  I don't believe this XCL has any components for Web development.

Hmmm.... looks like I'm stuck with my 328 Kb app.
0
 

Expert Comment

by:vanbeek
ID: 2745061
If docking support is not a concern, you might want to compile using D3 instead of D5 (or 4). This will further reduce the size of your applications.
0
 
LVL 1

Author Comment

by:nrico
ID: 2745137
I only have D4. I'm afraid that is not an option :-).
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2746155
I once got a program source, exe included.. the exe waw 56 KB.. when I compiled the source i got 300 KB .. how he did it ?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2746332
maybe upx, bryan ;-)

hi nrico,

well, was just an idea, i use it for apps, where the user must do a remote-dial in into network, to reduce the transmission-time. nevertheless, a smaller exe-size saves loadingtime, and
the decompressing is really fast.

meikl
0
 
LVL 1

Author Comment

by:nrico
ID: 2787548
kretzschmar, I'll check this UPX out then get back here.
0
 
LVL 1

Author Comment

by:nrico
ID: 2793875
Wow, this UPX is really useful! I get at least 50% off of my Delphi EXE's!

Though I'm not going to use it for my CGI project (I don't know if it'll run on the server's platform, which is most likely unix), but I certainly will for my other exe's!

kretzschmar, you'll get the points!
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2799556
Please could some one send this page to me and it's contents for example if there is an application or tool.
My stupid proxy won't move me to that site:
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html 

Motaz
motaz1@yahoo.com
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
Delphi IDE crash without error message ... 7 76
Delphi 2 48
Firemonkey webbrowser scrollbars ? 1 29
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

20 Experts available now in Live!

Get 1:1 Help Now