Link to home
Start Free TrialLog in
Avatar of ampcats
ampcats

asked on

how can I slim down the resources needed

delphi 5 I have written a prog... ALL it does, it trap a single API call, bring up a dialog box, detect 3 button clicks, and one mouseover - source text size 1K... - dfm+pas+dcu+dpr = 8K application size 470K - resources needed - 3072Kb (672 physical)

how can I slim it down...

A.
Avatar of h_p_soft
h_p_soft

Hello.

I'd need to know more about your program to say for sure, but one thing to try is to reduce the number of delphi VCL controls you use.

Good Luck!
project options/ click build with runtime package. Now your app will be very small but you have to attach some of those .bpl with you. (only the one contains component you use)
you can use this product "shrinker". it works fine . (it claims that can decrease exe size up to 60%)

http://www.activexcatalog.com/html/shrinker.html

http://www.drbob42.com/reviews/tools/shrink.htm

this site also has comment for shrinker (product of Blink Inc).
listening.

if you really need to build something small, there is a vcl replacement project (open source) that allow the building of very small exe have a look here
http://delphree.clexpert.cz/pages/app_XCL.htm
Anyway, XCL is called KOL now... and mhervais is right, you get really slim apps.
and if you heeding Tussin's comment, get something better.

UPX a.k.a. Ultimate Packer for eXecutables (http://upx.tsx.org) is a nice alternative... makes your files small, and it comes with source!

PS: Don't forget to check the rest of the sites for some nice compression algorithms.
If your program has no GUI (or almost no GUI) at all, you can also throw out the VCL completely and use pure win32 API. A bit ugly to use, but this will result in the smallest exe.

Regards, Madshi.
uses assembly language haha!! kidding
2 suggestions
if you want to make very small apps without the VCL check out this site. I think you'll find all you need there

http://xcl.cjb.net/

or use a compressor

I use aspack (www.aspack.com) for all my delphi/c++ programs and it typically reduces the size by half without you having to do anything.

Patrick
Avatar of ampcats

ASKER

h_p_soft - in uses clause are... stdctrls, controls, buttons, classes, forms, messages, windows, extctrls, dialogs, shellapi

leaving any out results in failed compilation...

tussin(1) - i want it to be self contained - I hate it that programs need to create thier own external libraries....

tussin(2), (3) - packing will reduce the size of the executable on disk (to 180K) but in memory adds to overall resources used - that is one thing I'm trying to reduce!


mhervais - I've had a look, and  will download, but I'll have to read thru the docs as where to put it in (and what to remove from my existing program... cheers...

madshi - my dfm is 3.8K - would like to create the form manually - then it wouldn't flash onto the screen for a fraction of a second on boot - it can be created when the process is called... agree that cutting out the form will cut the size down (unsure by how much) - if I could understand how to....

tussin (4) - WOULD LOVE TO!!!! I used to code in 8 and 16 bit, but never got hold of the build process for windows - where you call external routines when you don't know where they are sitting at run-time.... yes - I got scared by the API! (I still have masm - but even this simple prog seemed above my ability in win32 asm... <ashamed to say>

plc - you were beaten to both your suggestions...

A.


>> madshi - my dfm is 3.8K - would like to create the form manually

Just creating it manually will not reduce exe size.

>> then it wouldn't flash onto the screen for a fraction of a second on boot

Just in your project file (*.dpr) set "Application.ShowMainForm := false;" before "Application.Run", this will get rid of this problem, too...

>> it can be created when the process is called...

Heh? Don't understand what you mean...

>> agree that cutting out the form will cut the size down (unsure by how much) - if I could understand how to....

My suggestion was meant this way:

Delete the units "stdctrls, controls, buttons, forms, extctrls, dialogs" (and every unit which imports any of the above) from the uses clauses of every unit and from the uses clause of your project.
That means you can't use any visual components anymore. If you need any GUI in your program, you can only use CreateWindow(Ex) to create a form and the controls on it. This way an empty Delphi app is about 16KB long.
This all makes sense only, if the exe size is very important for you - and if you don't have much GUI.

Regards, Madshi.
It traces off. Normally, if you optimize the size, the performance will be decrease a bit.
Avatar of ampcats

ASKER

if i couldn't hide it totally on startup, then I was thinking if i could save resources, and only create the form when I need it - instead of it sitting as an invisible form until needed.... - but since you gave me the showmainform - all is fine!

it is the resources I am concerned about - a 400K program should not need to consume 3mb of virtual space.... it is pathetit... I would rather the program be 4mb, as long as it only used the 400k of memory that it takes up (and even 400k is excessive for what this does....)

cannot see createwindow(ex) anywhere... is this a win32 module as opposed to delphi?

getting rid of the units stated will prevent me from creating the form at startup.... which is great - then there will only be the code area in mem (as opposed to a hidden window and the code...  I will have to scour the win32api and find out how to create windows that are centered....

A.
Avatar of ampcats

ASKER

waddya mean tussin? - pure code is ALWAYS the fastest way to do something.... - it is this interpreted rubbish that is the need for faster PC's...

A.
Avatar of ampcats

ASKER

and pure code is the smallest....... where is the compromise...  I just wish I had persevered with the MC after windows came out...

A>
>> it is the resources I am concerned about - a 400K program should not need to consume 3mb of virtual space.... it is pathetit... I would rather the program be 4mb, as long as it only used the 400k of memory that it takes up (and even 400k is excessive for what this does....)

But the virtual memory is no big problem. I don't think you need to worry about that too much. What I don't like is the mere exe size - especially if someone wants to download such an exe.

>> cannot see createwindow(ex) anywhere... is this a win32 module as opposed to delphi?

It's a pure win32 API. Type "CreateWindow" in your Delphi editor and press F1. It's defined in windows.pas. But it's quite difficult to use...
Avatar of ampcats

ASKER

no the VM isn't a big prob, because people just 'accept it' because 'that is the way things are'.... 10 years ago, I didn't have that much RAM, - it is not for distribution - but for 10 PC's here that need a reminder to pop up on shutdown.... I don't want all that being used throughout the entire day, just to say OI! on shutdown, 8 hours later!!!

if no-one can help me shrink the vm area, then I'll just give you the pts, and go and look at masm again...

A.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

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
What I mean is the smallest code is not the best performance code. Yeah we can get smaller code as well as good performance but in this case the code is not smallest.
Avatar of ampcats

ASKER

basically - I want to know if it is possible to strip out the uses components down to the individual components that I am using.... eg - creating a box - i just wrote a program that prints nothing to the screen, just pauses till I press a key - it is 160K - that is rubbish - in DOS i can write it in 11 bytes....   is there a way??

yes   or no...

A.
You *CAN* throw out all the units you don't need anymore - no problem at all! But you have to watch: All the VCL sources are somewhat cross-linked. E.g. forms imports controls and controls imports forms. So when talking about the VCL you have to throw out EVERYTHING or NOTHING.
You want to create a box? Which kind of box do you mean? If you can live with windows.MessageBox, then you can simply delete all the units I mentioned earlier already, since MessageBox is no VCL, but pure win32 API.

Regards, Madshi.

P.S: I've the feeling that I'm telling you the same over and over again...   :-(
Avatar of ampcats

ASKER

you ought to be a politician - both yes and no answers in the same post.... have the pts - you can't see the wood for the trees, and are evidently looking foward to the day that your compiled equivalent of

for f=0 to 10: print f: next f

hits the 100mb mark..... there used to be programmers...

A.
Next time please delete the question instead of punishing me with a C grade...   :-(

>> you ought to be a politician - both yes and no answers in the same post

I don't understand what you mean. I've answered your question as good as I could. If you want more specific answers you have to ask more specific questions.

If you ask me: "Can I delete those units from the uses clause?" I can't simply say "yes". I *MUST* add, that in this case you can't use any VCL stuff anymore. If I would not have said that, my answer would have been imcomplete.

>> you can't see the wood for the trees

Do you mean *me*? You mean *I* can't see the wood for the trees?

>> and are evidently looking foward to the day that your compiled equivalent of [...] hits the 100mb mark.

I guess you mean me? Such a nonsense... I've recently built a tiny little 40KB installation utility with Delphi which handles everything from installing/upgrading/uninstalling etc. Nobody wants big exes.

>> .... there used to be programmers

I'm sorry, perhaps I misunderstand you, but your whole last comment sounds like a big insult to me...
Avatar of ampcats

ASKER

#include <sense>

no, madshi - it was not directed at you - it is so annoying that there are no ways to write small programs anymore... (if they are small, then they rely on MB's of 'libraries' being present).  everything is written on the basis of 'you can always get more ram / faster processor / bigger hard drive' - which is not the way things should be written - and if it is not possible to get that program down to less than 10K then i'll eat my hat.... and bin my PC's...

despair hits home........ returning to masm i think....  when i've done it, i'll return....

A.