Jump to content
gioma

Reduce exe weight : Link with runtime package

Recommended Posts

Hi,
I have a project in Delphi 12.2 of an exe that extracts other EXEs always made with delphi. I would like to reduce the weight of these executables, I thought of using the "Link with runtime package" option and linking the programs with the two largest BPLs VCLxxx.BPL and RTLxxx.BPL.
The problem is that adding RTL to the list of "Runtime packages" does not produce any reduction in the weight of the EXE.
Why I get this result?
Thanks

Share this post


Link to post

Does your project use multiple build configurations (debug/release, 32bit/64bit, etc)? Do you have the runtime packages applied to every configuration? 

Share this post


Link to post

I only set these options for the release build.

 

image.thumb.png.4b692daecfef186df6f09ee879271e14.png


A strange thing happens: if I add only "vcl" when I start the EXE, it requires both VCL and RTL.
Why is this?

Edited by gioma

Share this post


Link to post
12 minutes ago, gioma said:

if I add only "vcl" when I start the EXE, it requires both VCL and RTL.
Why is this?

Because the VCL depends on the RTL. If you use the Runtime Package for the VCL then you need the Runtime Package of the RTL as well. 

  • Like 1

Share this post


Link to post

But I don't get it, compared to two BPLs weighing a total of about 22 MB, I only have a saving of 6 MB... mah!

Share this post


Link to post

That is most likely because you only use a small part of these packages. When building a monolithic exe the compiler will only take the parts actually used, but the packages contain a lot more.

  • Like 2

Share this post


Link to post

I have made an application that copies the Delphi RTL/VCL source files into a temporary folder,  inserts the text '{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}' in the right places and re-builds the whole lot.  The compiled *.dcu files contain a lot less RTTI than before. 

 

By linking against this compacted RTL I achieve a size reduction in a 64-bit VCL application from 14 MB to 10.3 MB using Delphi 12.

 

For just a single executable that isn't worthwhile, but I use this in some multi-module projects that consist of a few dozen ActiveX EXE's and DLL'S. There the cumulative size reduction is substantial.   Proper testing is hugely important, one has to be sure that the missing RTTI doesn't cause the program to malfunction. 

  • Like 1

Share this post


Link to post

If it simply the size of the .exe you are looking to reduce, I use UPX, https://github.com/upx/upx/releases,  it handles 32 & 64 bit Apps.

I use a compression value of 7 and get a roughly 30% reduction in .exe size.  It will also handle wild card file names, i.e. upx -7 *.exe.

Share this post


Link to post
24 minutes ago, Ian Branch said:

If it simply the size of the .exe you are looking to reduce, I use UPX, https://github.com/upx/upx/releases,  it handles 32 & 64 bit Apps.

I use a compression value of 7 and get a roughly 30% reduction in .exe size.  It will also handle wild card file names, i.e. upx -7 *.exe.

Never do this. It's pointless, defeats stuff the OS does to make accessing data in the file efficient, triggers more false-positives, and provides no real benefits, unless you are dealing with a severe lack of storage on the deployment target, which should be fixed in other ways. You can zip the file for transmission bandwidth savings.

  • Like 4

Share this post


Link to post
1 hour ago, Ian Branch said:

If it simply the size of the .exe you are looking to reduce, I use UPX, https://github.com/upx/upx/releases,  it handles 32 & 64 bit Apps.

I use a compression value of 7 and get a roughly 30% reduction in .exe size.  It will also handle wild card file names, i.e. upx -7 *.exe.

I'd strongly advise against UPX especially in production executables. I had my fair share of after-the-last-moment struggle because of it

 

  • Like 1

Share this post


Link to post

Hi Guys,

I acknowledge the previous two commentors and their valid inputs, however it is horses for courses.  I was simply offering a suggestion.

I have used UPX for many years without any issues.  Note:  I use Eurekalog not MadExcept.

It provides not only compression, but also therefore a small level of obfuscation to casual file browsers.

That is all I need.

4 hours ago, Brandon Staggs said:

defeats stuff the OS does to make accessing data in the file efficient

Like?

4 hours ago, Brandon Staggs said:

You can zip the file for transmission bandwidth savings.

Yes I could, but, the other end is so computer illiterate that they would screw up the unzip and save process.  Pacific island users.  It has to be simple for them to just copy into their directory.  Even then they screw it up sometimes...:-(

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×