Solved

Reducing size of Delphi exe file

Posted on 2006-06-19
13
342 Views
Last Modified: 2010-08-05
I have written a program in Borland Developer Studio 2006 for Win32. The program is based on the PageControl component. My PageControl contains 12 TabSheets. Each of these TabSheets has a number of database aware components - edit boxes, radio groups and so on, maybe an average of a dozen components per TabSheet. The executable is massive at over 7 MB. It takes about 2 minutes just to load. After loading, it works well enough. But the loading takes so long, one gets the impression the program has hung up. To streamline it, do I need to create the components (or the Tabsheets) dynamically when I need them? Rather than creating every page at design time? If that's what I need to do, what would be the steps I would need to go through and would it be a huge task or something quite quick and easy (I'm a casual Delphi programmer not an expert!).

Regards,
Peter
0
Comment
Question by:riskassessor
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 300 total points
ID: 16936868

Everything getting loading in your applicaiton. Also the Applicaiton eats lots of memory.

Instead of 12 Tabs it is better to use the Forms and create those forms dynamically.
Create a main form and navigate it from to other forms. You can create form dynamically when to navigate.

Go to    Project>Options>Forms> move all the created froms to left to right except the Main form.

Also try to use  datamodule to place the DB components.
Don't open the all the tables in the begining of the applicaiton. Open the tables only when it is needed.

Instead of Tab and creating the form dynamically will load the application quickly.


Hope this helps

sun4sunday
0
 

Author Comment

by:riskassessor
ID: 16937147
Those sound like good suggestions - but would I have to recreate the user interface from the beginning? Is there any way I can quckly convert what I already have to a more efficient program?
0
 
LVL 9

Assisted Solution

by:sun4sunday
sun4sunday earned 300 total points
ID: 16937393
>>It takes about 2 minutes just to load.
This is too long for an an applicaiton to just to get load.
What I suggested is  to reduce the loading time/performance of the applciaiton.

In my view Loading time is more important than the size of the exe.

If you want reduce the size
http://upx.sourceforge.net/   or use ASPACK

or u have to go with WinAPI coding.

Also cross check this
Project|Options and select the Linker tab, set Map File to Off, set Linker Output to Generate DCUs and untick all the EXE and DLL options.

sun4sunday
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:riskassessor
ID: 16937460
I agree - the loading time is the biggest problem since it seems to run fast after loading. But I already have Map File off and Linker Output to Generate DCUs and the EXE and DLL options are already unticked, so that suggestion is already implemented and it's still slow to load.
0
 
LVL 9

Assisted Solution

by:sun4sunday
sun4sunday earned 300 total points
ID: 16939283
Have you opening all the tables when you are loading the applicaiton. If so, change that according to the above post.
>>Is there any way I can quckly convert what I already have to a more efficient program?
Witth out modifying anything, the loading time will not get improve.
The first thing is the enitre bulky form with all the tabs, If you can change it to the form and open necessary tables on the right time . Hope that will resolve the problem

By the way is how old is the comptuer at the client side? If it is old the performance will effect.
Also if your data retriving throught the network, then the spped of the network also a factor to open your applicaiton.

sun4sunday
0
 
LVL 9

Assisted Solution

by:sun4sunday
sun4sunday earned 300 total points
ID: 16939304
>>, so that suggestion is already implemented and it's still slow to load.

This is one reason to get the exe bulky. in your case it is ok.

Check othe r two suggesions :) Move Tas to forms and change all tables opes in the begining.

sun4usunday
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 16939345
Also if your database is fresh, (means very few records in it) and once your databse grows, the opening the tables will  take more time and it will effect the opening time of the application.

sun4sunday
0
 
LVL 10

Assisted Solution

by:atul_parmar
atul_parmar earned 50 total points
ID: 16940243
1. If there is NO optimization scope then create a beautiful sphash screen and show the loading progress. This will not reduce the loading time but sure it will not get an impression of hanf up
2. Having dozens of components doesn't affect much in loading time. I mean it doesn't take much time to create them all.
3. The most time taken is by creating and opening database connections, opening tables, filters, master-details tables etc. So delay the opening of tables as much as possible. e.g. The table used in tab2 ...tabN can be opened only when needed (i.e. when user clicks that tab)
4. To reduce the exe size,
    1. remove the units from uses list which you are not using.
    2. when you compile your final exe, turn the debugging off
0
 
LVL 15

Assisted Solution

by:mikelittlewood
mikelittlewood earned 50 total points
ID: 16941304
1st of all, take all the unused units of your uses clause.

Another thing that you can and definitely SHOULD do is to turn off the compile with debug information.
If you are using any resources, such as bitmaps,wav's etc... compile them separately as resource files.

When ever you can, create dynamical forms and components.
Could also use http://www.neoworx.com/neolite/download.asp and try it out!
NeoLite will compress EXE / DLL / OCX files while maintaining optimal performance when executed

Go get the free UPX exe compressor
http://www.nexus.hu/upx/ 
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16941744
I think I have re-iterated a few of atul_parmar's points from before I just noticed. Sorry about that atul_parmar.

But check out the other 2 applications from reducing exe's.
0
 
LVL 4

Assisted Solution

by:David_Ward
David_Ward earned 100 total points
ID: 16958804
Heres a thought ......

You could try compressing it with something, like, say, UPX.
UPX is shareware and should compress your EXE to at least one third of its' current size.

0
 
LVL 4

Assisted Solution

by:David_Ward
David_Ward earned 100 total points
ID: 16958817
p.s. you can find it here:

http://upx.sourceforge.net/
0
 

Author Comment

by:riskassessor
ID: 16961311
Thanks to all who helped me on this. I think the key to reducing the EXE file size and the loading time is to dynamically create forms when needed and then delete them when done as Sun4Sunday pointed out. No one answered my question on the steps for doing this but I have managed to figure it out and the program is well on the way to being rewritten. It is a fraction of the former size and loads almost instantly. I may also use an EXE compressor so thanks to those who pointed that out. I have split the points between all who gave useful help. Thanks again.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Simple Delphi Question 9 89
Comparing dates in Delphi. Greater than/ Less than 3 148
scroll down TListBox component in Delphi 1 7
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

10 Experts available now in Live!

Get 1:1 Help Now