Link to home
Start Free TrialLog in
Avatar of yingkit
yingkit

asked on

Ways to reduce EXE size and memory usage.

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.
Avatar of chengjian
chengjian

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

Avatar of yingkit

ASKER

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!  :-)
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.
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
good idea
but the total size is not reduced and the total memory usage is also not reduced:-)
when you create forms dynamicaly , and DLL usage  will reduse memory usage.

Regards



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.
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.
Yes chengjian is right .
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


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
ASKER CERTIFIED SOLUTION
Avatar of chengjian
chengjian

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi chengjian ,
I don't see annything that is your
sugestion in this answer !?

What exactly is your answer ??
the rejected answer perhaps is:-)