Application size

Why are my Delphi applications always so big, and what can I do to reduce their size??
LVL 1
nricoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kretzschmarConnect With a Mentor Commented:
another idea,

did you thought about to use upx

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

meikl
0
 
DrDelphiCommented:
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
 
kretzschmarCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
nricoAuthor Commented:
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
 
DrDelphiCommented:
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
 
nricoAuthor Commented:
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
 
nricoAuthor Commented:
I don't have any forms (just a few TPageProducers), and I'm not willing to settle for that size.
0
 
DrDelphiCommented:
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
 
nricoAuthor Commented:
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
 
kretzschmarCommented:
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
 
nricoAuthor Commented:
Yes, kretzschmar (nice picture BTW ;-), pressing F5 is potentially dangerous for the question... :-)
0
 
kretzschmarCommented:
oops, posted twice :-))

the httpapp-unit uses forms
0
 
kretzschmarCommented:
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
 
DValeryCommented:
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
 
MotazCommented:
What is the purpose of Debug info

Motaz
0
 
ZdhankoCommented:
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
 
ZdhankoCommented:
{file spray.dpr}
program spray;
{$APPTYPE CONSOLE}
uses  SysUtils,Classes,mxarrays,inifiles;
 ...
procedure ReadSprayIni;
begin
....
end;

begin
 ReadSprayIni;
end.
0
 
MotazCommented:
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
 
ZdhankoCommented:
My solutiion not for such a program,
but for another types works good.
0
 
nricoAuthor Commented:
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
 
vanbeekCommented:
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
 
nricoAuthor Commented:
I only have D4. I'm afraid that is not an option :-).
0
 
bryan7Commented:
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
 
kretzschmarCommented:
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
 
nricoAuthor Commented:
kretzschmar, I'll check this UPX out then get back here.
0
 
nricoAuthor Commented:
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
 
MotazCommented:
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
All Courses

From novice to tech pro — start learning today.