Forum > Windows

How to reduce EXE program size?

<< < (12/14) > >>

ASBzone:

--- Quote from: FlierMate on April 11, 2021, 02:16:54 pm ---My simple "Hello World" program is 49,815 bytes. Hmm..., can we strip it of unused libraries / data?

The attached picture shows the code section of that size, in which I think the rest of EXE are unrelated to displaying "Hello World" text string on console screen?

I thought I want to attempt writing a compress tool for FPC but (1) the output EXE is far more complicated that I thought, (2) it is best if it is done by the developer of the FPC itself (i.e. not outsider like me).  :D

Thank you for your attention.

--- End quote ---

A couple months back, I performed some informal testing across the systems on my network with varying executable sizes from a couple of applications, and came away with the following conclusions:

-- There is no substantial difference between the performance of one executable and another unoptimized version of the same, until there is at least a 250K size difference.
-- The newer the machine, the larger the difference in size needs to be, in order to make it noticeable -- even with logging
-- 10 year old systems running Windows are only a few dozen milliseconds slower in starting up than newer systems
-- The greatest contributing factor in startup performance is what AV or other end-point protection you are running  (I could literally shave 15-20 ms off the startup time based on which AV app was used)

It is such a non-factor that you will likely never reclaim the time you spent trying to optimize the performance via size.


Fred vS:

--- Quote from: FPK on April 11, 2021, 08:38:18 pm ---
--- Quote from: Fred vS on April 11, 2021, 08:03:10 pm ---
--- Quote from: winni on April 11, 2021, 07:48:11 pm ---Hi!

I recognized that some people don't have a feeling what a kilobyte is related to a gigabyte. For those a graphic is always helpfull.

In the attachment.

Winni

--- End quote ---

Here with arduino 32 Kb ram + 2 KB flash.

--- End quote ---

% fpc11avr -Wpattiny10 empty.pp
Free Pascal Compiler version 3.3.1 [2021/04/11] for avr
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Embedded
(3104) Compiling empty.pp
(9009) Assembling program
(9015) Linking empty
(1008) 2 lines compiled, 0.0 sec, 94 bytes code, 0 bytes data

--- End quote ---

Thats the way, héhé, héhé, I like it.

 ;D

ASBzone:

--- Quote from: FlierMate on April 11, 2021, 02:16:54 pm ---My simple "Hello World" program is 49,815 bytes. Hmm..., can we strip it of unused libraries / data?

--- End quote ---

One other point I intended to mention, but forgot.

Does it really matter what size "Hello World" compiles to, if "Hello World" is not your final product?    Meaning, you might go through all the work to strip down the RTL (or something else) to provide the barest of minimum sized executable, when that isn't your actual use case, and then you find out that all the things you stripped out are very much needed by the actual code you want to produce.

If you're even going to go through this exercise at all, shouldn't you at least do it with meaningful code that you actually need to run, and want to end up with?

Because it makes little sense to optimize anything else.  ;) ;)

Dodfr:
Hi,
 
If your dev skills are pascal oriented and you still have a "good old" Delphi7 you may use KOL/MCK libs that permit to create very small apps including with visual components (limited to those from MCK libs that reproduce a lot of standard VCL component palette).

Simple helloworld inside a Form is 23KB, console version is smaller, adding visual components (MCK-KOL not VCL) do not increase size a lot.

A simple helloworld console mode is 8KB if I remember well.

Also to make EXE even smaller you can use ASM inline version of KOL libs instead of Delphi coded version.

Other trick with kol you can replace the standard sysutils with the one optimized with KOL.

So if you have some size coding contest and you are more comfortable with Pascal language than C/C++ then go for Delphi7+KOL/MCK, and whenever KOL/MCK development stopped I still use it time to time if I want small exe sized apps.

Appart from KOL/MCK if you want to reduce size of an EXE you can use strip.exe and EXE compressor like UPX (I think UPX do strip itself).

Regards.

avra:
KOL is not Delphi only. It works with our favorite compiler as well...
https://wiki.freepascal.org/KOL

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version