Reducing size of Delphi exe file

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!).

Who is Participating?
sun4sundayConnect With a Mentor Commented:

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

riskassessorAuthor Commented:
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?
sun4sundayConnect With a Mentor Commented:
>>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   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.

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

riskassessorAuthor Commented:
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.
sun4sundayConnect With a Mentor Commented:
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.

sun4sundayConnect With a Mentor Commented:
>>, 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.

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.

atul_parmarConnect With a Mentor Commented:
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
mikelittlewoodConnect With a Mentor Commented:
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 and try it out!
NeoLite will compress EXE / DLL / OCX files while maintaining optimal performance when executed

Go get the free UPX exe compressor 
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.
David_WardConnect With a Mentor Commented:
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.

David_WardConnect With a Mentor Commented:
p.s. you can find it here:
riskassessorAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.