Solved

Application size

Posted on 2000-04-23
27
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month4 days, 2 hours left to enroll

630 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