* * *

Author Topic: to optimize big EXE file.  (Read 3012 times)

delphiturk

  • New member
  • *
  • Posts: 6
to optimize big EXE file.
« on: January 16, 2012, 01:35:15 am »
 Lazarus and I started to develop software that has amazed me the most important case, the assembly was the result of a large binary file. UPX is a result of researches for this software, and I've created this software easier to use an intermediate software. also wanted to share it with you.
Good luck to all.

download :
http://www.delphiwise.com/binoptimizer/binoptimizer-setup.exe
« Last Edit: February 11, 2012, 10:47:00 am by delphiturk »

miquelmatas

  • New member
  • *
  • Posts: 28
Re: to optimize big EXE file.
« Reply #1 on: January 16, 2012, 09:51:59 am »
 :)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1182
Re: to optimize big EXE file.
« Reply #2 on: January 16, 2012, 10:01:55 am »

TurboRascal

  • Sr. Member
  • ****
  • Posts: 457
  • "Good sysadmin. Bad programmer."™
Re: to optimize big EXE file.
« Reply #3 on: January 20, 2012, 03:25:16 am »
Also remember that what UPX does is not all that great, as they say "there is no such thing as free lunch" :)

Research about the side effects well, and only then decide if it's worth it...
Regards, Arny the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

delphiturk

  • New member
  • *
  • Posts: 6
Re: to optimize big EXE file.
« Reply #4 on: January 20, 2012, 10:33:50 pm »
http://upx.sourceforge.net/ UPX file is freeware. you goto http://upx.sourceforge.net/ and see. I just tried to make it more useful. That's all.

thanks..

TurboRascal

  • Sr. Member
  • ****
  • Posts: 457
  • "Good sysadmin. Bad programmer."™
Re: to optimize big EXE file.
« Reply #5 on: January 21, 2012, 03:00:57 am »
Yes, we know what upx is and where to find it, thank you  8) It's also not really "freeware" but free and open source software... Also there are many of us who don't think it's wise to use upx without a specific reason, details are on the link which Marco posted before...
Regards, Arny the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

User137

  • Hero Member
  • *****
  • Posts: 503
Re: to optimize big EXE file.
« Reply #6 on: January 21, 2012, 12:06:36 pm »
The executables that Lazarus does for me on Win32 applications are roughly 1.5Mb. It's already so small that its hardly noticable. When i distribute my applications they are put in a .zip file. UPX files are already compressed so .zip would not make them any smaller in the end.

powtils

  • New member
  • *
  • Posts: 18
Re: to optimize big EXE file.
« Reply #7 on: January 23, 2012, 04:24:12 am »
The executables that Lazarus does for me on Win32 applications are roughly 1.5Mb. It's already so small that its hardly noticable.

LOL, but a full featured complex C++ program like EditPlus is only about 1.5MB, and it is a full featured text editor.. how can it only be 1.5MB?

A hello world should not be 1.5MB. With this attitude, as hard drives get bigger and there is more and more DSL/Cable internet available, why not justify Microsoft .NET too?

Sarcasm:
A 100MB microsoft .NET download is nothing these days. It's fast for me to download 100MB .NET runtime.. takes only a few seconds. And on my hard drive, 2TB or whatever, who cares about a 100mb .NET runtime? And also, computers are so fast, 3GHz, so the slowness of .NET or Java is irrelevant today due to Moore's Law!
End Sarcasm.

Then you have something like KOL for delphi, which uses all sorts of tricks to get the Exe size down to 20-30KB, but the problem with KOL/MCK is that it is not as safe. It uses old borland objects rather than classes, and not many developers develop KOL components.

Something inbetween would be nice. 300KB exe's would be nice.

MSEGUI is in between it creates not as much bloat. MSEGUI is okay, but it feels alien and foreign, not as native looking as delphi applications.  MSEGUI widgets remind me of java widgets that don't look as native on your screen.

It does depend on the situation.. but, I for one, enjoy applications like EditPlus on Windows, which is only about 1.5MB in size and still has lots of features! If they can do that, the LCL could do it too, and create only 500KB exe's. Problem is, it would require more developers, and most lazaraus developers could care less about bloat and size, they are more concerned about getting the product out the door with more features using our existing technology and not optimizing it.

Size is a good indicator of the snappiness of an application. It's not a direct indicator.. a 1KB program could still be slow, while a 10MB application could be fast, it depends on the situation entirely. But there is something about snappy small applications that makes power users and programmers happier people. Just look at the failure of the Delphi product that was slow loading and relied on .NET, which people trimmed down and offered Lite snappier versions.
« Last Edit: January 23, 2012, 04:41:11 am by powtils »

Leledumbo

  • Hero Member
  • *****
  • Posts: 2989
Re: to optimize big EXE file.
« Reply #8 on: January 23, 2012, 04:55:22 am »
Quote
LOL, but a full featured complex C++ program like EditPlus is only about 1.5MB ! A hello world should not be 1.5MB. With this attitude, as hard drives get bigger and there is more and more DSL/Cable internet available, why not justify Microsoft .NET too?
Does EditPlus runs on at least 8 different combinations of cpu-os? With at least 4 different GUI backends? Are you sure you've counted all the size instead of just the exe (I'm talking about dll dependencies)? If you have any chance to see the source code, how many things must you write from scratch?

FYI, g++ hello world eats up 500K, stripped down to 128K (if no debugging symbols included), as a console app. Try writing a GUI version, with any toolkit (not a direct API call), as none is comparable to LCL for now, and see the resulting size yourself. VC++ takes much smaller, but again, consider above points (specific-platform-ism do help in tighter library design).

Day by day LCL gets refactored, sometimes it decreases the exe size, sometimes it increases due to some design feature requirement. And since Lazarus isn't meant to write only hello world or some other equivalent small programs, I think the size isn't a problem. What's written in wiki is correct from my experience, the exe size grows only by a small portion as you add more and more components. Try the same with QtCreator or wxDev-C++. Don't forget to count the dll size.
Quote
A 100MB microsoft .NET download is nothing these days. It's fast for me to download 100MB .NET runtime.. takes only a few seconds. And on my hard drive, 2TB or whatever, who cares about a 100mb .NET runtime? And also, computers are so fast, 3GHz, so the slowness of .NET or Java is irrelevant today due to Moore's Law!
Not all countries have the same situation as you, even in many countries such up to date hardware and internet connection only applies to big cities. The speed of .NET or Java is still relevant, 3 GHz is not fast enough, even in my Core i3 2100 with 4 GB RAM it's still not fast enough. The startup is *VERY* slow, sophisticated algorithms are slow, and many other things. Only RAM could be counted as acceptable now (around 100 MB for typical apps, down to 30 when idle) even though it's still far compared to native code (around 6-20 MB for typical apps, Lazarus itself eats 30, down to 1-less than 10 when idle).
Quote
Size is a good indicator of the snappiness of an application. It's not a direct indicator.. a 1KB program could still be slow, while a 10MB application could be fast, it depends on the situation entirely. But there is something about snappy small applications that makes power users and programmers happier people. Just look at the failure of the Delphi product that was slow loading and relied on .NET, which people trimmed down and offered Lite snappier versions.
Delphi 7 and prior FireMonkey era used to be able to generate executables of such size. It's bigger (even bigger than LCL) now since FireMonkey, got any idea why? ;)
« Last Edit: January 24, 2012, 05:05:02 am by Leledumbo »

BigChimp

  • Hero Member
  • *****
  • Posts: 1012
    • CheckRide remote control and other open source projects
Re: to optimize big EXE file.
« Reply #9 on: January 23, 2012, 05:23:35 am »
Very glad upx got taken out of the windows default FPC install for the reasons given above... Who wants to write hello world apps anyway... and then complain about the size once they know why it's so big (I think the size FAQ explains it very well)...

As for putting more Lazarus developer effort into shrinking exe size versus LCL stability, cross-platform support and feature set, I'd go for the latter as it doesn't yet feel too bloated to me. Of course, I only get some patches in... so who am I to say...

Just a minor nitpick:
It's also not really "freeware" but free and open source software....
Freeware is just a term. http://en.wikipedia.org/wiki/Freeware: freeware means software that you can get for free; the term  does not (strictly) imply anything about the license model/openness of source code... (Ok, most often it's used for closed source free stuff)
People push "free and open source software", and I actually agree that software is best served with source code anyone can modify...  but that has to do with licensing.
"free and open source software" is a subset of freeware: i.e.: all FLOSS is freeware (but not all freeware is FLOSS).

Just wanted to get that off my chest, hope I haven't taken too much of anyone's time and irritation tolerance ;)
CheckRide remote control and other open source projects:
https://bitbucket.org/reiniero/

TurboRascal

  • Sr. Member
  • ****
  • Posts: 457
  • "Good sysadmin. Bad programmer."™
Re: to optimize big EXE file.
« Reply #10 on: January 23, 2012, 06:23:04 am »
When i distribute my applications they are put in a .zip file. UPX files are already compressed so .zip would not make them any smaller in the end.

Now that you've mentioned that, UPX can even make it worse - if you pack your distribution package with more powerful compression tools like 7zip (which innosetup also uses for its installers) or .tar.bz2 (quite usual in the unix-like world) or newer .tar.xz (latest LZMA variant), you would notice the package getting bigger for UPX-ed binaries. The reason is that UPX features comparably low compression (for speed),  and it's very hard for compression programs to compress already compressed data, even if the original compression is lower than their own.  ;)

LOL, but a full featured complex C++ program like EditPlus is only about 1.5MB, and it is a full featured text editor.. how can it only be 1.5MB?

A hello world should not be 1.5MB. With this attitude, as hard drives get bigger and there is more and more DSL/Cable internet available, why not justify Microsoft .NET too?

You yourself gave the pattern here, the bigger the runtime libraries, the smaller the program. The smallest executable would be the .NET one, with tens to hundreds of megabytes for the framework libraries. The next smallest would be a C++ like you said, but you forget that such programs also use runtime libraries, and C++ more so than C. Try also calling treating those libs as "bloat" like you do for .NET and have them NOT installed in your system, then let's see how good would the program work ;) Or try compiling the C++ program statically, I'm quite interested in how big it would be... FPC/Lazarus binaries are big because they are self contained, they have everything in them contrary to the above mentioned language runtime systems.

Not that I like the binaries are 1500 kbytes large, I'd much prefer those to be like 500 kbytes, but that's the matter of fact and Iwant to stress that using UPX won't remedy that in a good way.


Just a minor nitpick:
...
Freeware is just a term. http://en.wikipedia.org/wiki/Freeware: freeware means software that you can get for free; the term  does not (strictly) imply anything about the license model/openness of source code... (Ok, most often it's used for closed source free stuff)
People push "free and open source software", and I actually agree that software is best served with source code anyone can modify...  but that has to do with licensing.
"free and open source software" is a subset of freeware: i.e.: all FLOSS is freeware (but not all freeware is FLOSS).

Just wanted to get that off my chest, hope I haven't taken too much of anyone's time and irritation tolerance ;)

I know my message irritates you, it even irritates me when I see similar ones around ;) But it's not meant for you or me, it's for those who don't understand. People often don't understand the difference between "free software" and "freeware" so I believe they should be educated when that's evident... The counfusion starts with the unfortunate fact that "free" has two meanings in English, like RMS said "free as in 'free beer'" and "free as in 'freedom'". That's why (among other reasons) they coined the term "open source" later, so the meaning would be unambiguos.
Regards, Arny the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

BigChimp

  • Hero Member
  • *****
  • Posts: 1012
    • CheckRide remote control and other open source projects
Re: to optimize big EXE file.
« Reply #11 on: January 23, 2012, 09:05:47 am »
I know my message irritates you, it even irritates me when I see similar ones around ;) But it's not meant for you or me, it's for those who don't understand. People often don't understand the difference between "free software" and "freeware" so I believe they should be educated when that's evident...
Hi Arny, your crystal ball is working 100% ;)

I'm glad you are still motivated to educate people about free as in beer etc...

To (possibly, who knows) brighten up the mood, I've just released an iptabls log parser that dumps data in csv format. Looking around for parsers, I only found grep-like solutions that did not extract the data or only extracted some common subset, or... enormous monitoring packages with agents for imports.
So, yet another wheel reinvented, but it seems to work... testing (and Linux compile with FPC 2.5+) welcome...
https://bitbucket.org/reiniero/smalltools/
CheckRide remote control and other open source projects:
https://bitbucket.org/reiniero/

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: to optimize big EXE file.
« Reply #12 on: January 23, 2012, 01:34:40 pm »
LOL, but a full featured complex C++ program like EditPlus is only about 1.5MB, and it is a full featured text editor.. how can it only be 1.5MB?

Mind, I am not saying Lazarus is as optimal as it could be with regards to exe size)....

But this may be comparing apples and bananas. depends how the c++ was put together...

Any app written in an RAD environment (http://en.wikipedia.org/wiki/Rapid_application_development) will have a bigger exe (including anything hidden in libraries and runtime packages...) than the same app written all by hand...

You put a form in your app, pulls in the entire form (at least all published). including those bits that you do not need.



felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3162
Re: to optimize big EXE file.
« Reply #13 on: January 23, 2012, 02:21:42 pm »
"Download EditPlus Text Editor
Supported Operating Systems
 Windows 7, Windows Vista, Windows XP"

Where is Linux, Mac OS X, Android? Ops ... it doesnt run on them =)

Well, Lazarus applications run on those, so we have more features = more code = more binary size.

Of course that if you make a single-platform application it will be smaller, that is always the case. And compared to other widely used cross-platform frameworks Lazarus apps are much smaller. Check how big is the runtime required for Gtk in Windows, I think it is something like 200MB.

Bart

  • Hero Member
  • *****
  • Posts: 791
    • Bart en Mariska's Webstek
Re: to optimize big EXE file.
« Reply #14 on: January 23, 2012, 02:29:52 pm »
LOL, but a full featured complex C++ program like EditPlus is only about 1.5MB, and it is a full featured text editor.. how can it only be 1.5MB?

I wrote something similar, a texteditor mainly for HTML editing, with highlighers for several languages (EPlus) in Lazarus. It's 2 Mb (w/o debugging information).

Bart

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads