Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ways to reduce EXE size and memory usage.

Posted on 1999-07-20
14
Medium Priority
?
320 Views
Last Modified: 2010-04-06
Hello,
I want to reduce the size of the output EXE and the memory usage by the EXE, how can I do so?  Pls list as many ways as possible.
Thanks.
PS. Please dont suggest me to use a EXE compressor. :-)  The more ways you can give, the more points will be given.
0
Comment
Question by:yingkit
[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
14 Comments
 
LVL 1

Expert Comment

by:chengjian
ID: 1389777
hehe
a good question
First i sugest u to use ASPack¡ª¡ªa exe comptessor :-)
Second I sugest u use less component.
Third I sugest u do not use component(VCL) and use api directly
Fourth I sugest u use d3 not d4
fifth I sugest u edit ur complie option to shut Debug info stuff down
sixth I sugest u edit ur code
seventh U perhaps like XCL¡ª¡ªlike api but more easy to use but the size is larger than api:-)

That's what i could tell u. and I also want to find such answer for long time

0
 

Author Comment

by:yingkit
ID: 1389778
Hello Chengjian,
Thanks for your good answers.  But I want some answers like:
FreeLibrary(GetModuleHan......which can reduce the memory usage by releasing some libraries.
1.  Of course I know ASPack
2.  Less components don't always mean smaller EXE
3.  Not all components can be replaced with API.  At least you should give me some examples
4.  Hee...I'm using D2 but not D3 nor D4.
5.  From the Delphi help file, it states that debug info, or something else, which will NOT affect the size/speed of the EXE, it only affects the .DCU files
6.  Edit my code?  Good point, I will consider this.  ^_^
7.  The only thing I don't know is XCL, I have never heard of this, can anyone tell me what it is?
Anyway, thanks for your time to type the answers for me!  :-)
0
 
LVL 1

Expert Comment

by:chengjian
ID: 1389779
oh,bless me use d2? forgive me but i think it's the worest version of delphi:-(
Ok.Use less TYPE of component i think,for example. use TButton not TBitBtn, use TBevl not TPanel if not nessary it SHOULD work.

About your code, I think it's another way, I just means,  do not use unnessary code for example. perhaps less note?:-)

XCL i think u wouldn't like it. As I told u, it's a set of component, use it just like use api but more easy to use. u do not use TForm but XForm hehe,terrible! u wouldn't like it.

I wander what kind of stuff do u want?

In d4(I know u do not use that) just a app with only a form would cause more than 300 K! A friend of mine even want to modify the source code :-) //he use c/s version,how rich:-))
I am so sorry u do not like my answer:(
If any good idea, also let me know.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:Mariner080498
ID: 1389780
Hi ,
To reduce *.exe size , i prefer you some things
1. when is possible , use *.DLL-s.
2. Use *.res files for icons and any stuff like it (*.bmp)
3. instead *.res you can use also DLL-s or
   type full path to *.bmp -s (this is not good !!).
4. Also if you use OLE /COM object this will reduce size.
5. Use options in your project

To reduce memory usage , use CREATE and when finish with certain Form , FREE it.

Some of this sugestions will slow app. speed !

Hope that this will help.

Regards Marin
0
 
LVL 1

Expert Comment

by:chengjian
ID: 1389781
good idea
but the total size is not reduced and the total memory usage is also not reduced:-)
0
 

Expert Comment

by:Mariner080498
ID: 1389782
when you create forms dynamicaly , and DLL usage  will reduse memory usage.

Regards



0
 

Expert Comment

by:Mariner080498
ID: 1389783
Total size of your program will be the ~ same , but your *.exe will be smaller and maybe some faster.

And changing your code will produce main effect for memory, size and speed.

Also usage of memory in certain moment will be very diferent  from your current application.


I don't know other smart metods except this.


Regards Marin.
0
 
LVL 1

Expert Comment

by:chengjian
ID: 1389784
yes,yes
in addition:
use COM/OLE would increase memory usage
and use dll/res will increase total size,though just a little:-)

but i think it's not important in moderm programming.
The size is almost limited by the complier
You should improve your code by good arithmetic and data structure.
0
 

Expert Comment

by:Mariner080498
ID: 1389785
Yes chengjian is right .
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1389786
Like all of the above have mentioned, reducing the memory use and size of your program boil down to good programming practices.  But please keep in mind that with each successive version of Delphi, size and memory usage have gone up.  A program written with Delphi 2 and compiled with Delphi 2 will almost always be smaller and use less memory than the same code compiled with Delphi 3, and that would again be smaller than the same code compiled with Delphi 4.  BUT, the performance of that code, in many situations, has more than likely increased by a much larger margin than the memory and size did.  I have seen exe size increase by 40%, but the performance seemed almost triple what Delphi 2 put out.  There have been many optimizations made to Delphi between versions.  The only time I would recommend using Delphi 2 over a newer version is when writing apps that DONT use the VCL at all.  In that case most of the advantages of the newer versions are moot.  But honestly, if you are writing code like that, why use Delphi?  That really isnt what it was designed for.

Heath


0
 
LVL 1

Expert Comment

by:chengjian
ID: 1389787
thanx Mariner
heathprovost:
yes, I said (perhaps not:)),the size increase because borland add many propertise and mathod to VCL(some are never use by me:-)perhaps it's waiste), the only way to reduce the size is re-write these vcls, we would never do so at least me. perhaps in next version, borland could add some option to let we choose which propertise/mathod are required, but it seems imposible:-(
if the program is larger and the code is the same. i think the memory usage would increased, the performance perhaps not be affected much, but at least the time for load this program is increased:-)
yingkit: Sorry, i would put this as an answer,again. if u do not like it reject again. but i think it's all.
good luck
0
 
LVL 1

Accepted Solution

by:
chengjian earned 20 total points
ID: 1389788
thanx Mariner
heathprovost:
yes, I said (perhaps not:)),the size increase because borland add many propertise and mathod to VCL(some are never use by me:-)perhaps it's waiste), the only way to reduce the size is re-write these vcls, we would never do so at least me. perhaps in next version, borland could add some option to let we choose which propertise/mathod are required, but it seems imposible:-(
if the program is larger and the code is the same. i think the memory usage would increased, the performance perhaps not be affected much, but at least the time for load this program is increased:-)
yingkit: Sorry, i would put this as an answer,again. if u do not like it reject again. but i think it's all.
good luck
0
 

Expert Comment

by:Mariner080498
ID: 1389789
Hi chengjian ,
I don't see annything that is your
sugestion in this answer !?

What exactly is your answer ??
0
 
LVL 1

Expert Comment

by:chengjian
ID: 1389790
the rejected answer perhaps is:-)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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