Solved

Reducing size of Delphi exe file

Posted on 2006-06-19
13
339 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

11 Experts available now in Live!

Get 1:1 Help Now