Recent

Author Topic: Compiled file size query  (Read 4817 times)

tetrastes

  • Sr. Member
  • ****
  • Posts: 469
Re: Compiled file size query
« Reply #15 on: January 23, 2020, 03:55:06 pm »
As the LCL is currently statically linked into the application already this whole static binary would likely be larger than the static wxWidgets binary.
You will be suprized, but
Code: Bash  [Select][+][-]
  1. D:\wxWidgets-3.1.1\samples\minimal\gcc_mswu_32>dir
  2.  
  3. 2020-01-23  19:28         7 348 736 minimal.exe
  4. ...
  5.  
(yes, stripped), and this is much bigger than any of my Lazarus app (with much bigger functionality  8-)).
I suspect that Linux things are something like that.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11353
  • FPC developer.
Re: Compiled file size query
« Reply #16 on: January 23, 2020, 04:34:56 pm »
What's advantage of using packages then?

Primarily? NOT SIZE!

Packages are mainly to be able to compile parts of a program (e.g. a customer specific module) after the main program, without recompiling the original.

Thaddy

  • Hero Member
  • *****
  • Posts: 14169
  • Probably until I exterminate Putin.
Re: Compiled file size query
« Reply #17 on: January 23, 2020, 04:40:13 pm »
It is also an unfair comparison if you do not add the size of the package to the executable as well as any shared OS libraries.
FPC is well capable to produce binaries (without much dependencies) for embedded targets that are within a few hundred bytes....
Specialize a type, not a var.

luca

  • Jr. Member
  • **
  • Posts: 83
Re: Compiled file size query
« Reply #18 on: January 23, 2020, 04:53:15 pm »
To reduce the size of the compiled project I'm using UPX tool.

In my case the size passes from 11MB to 3MB

Regards
Luca

Thaddy

  • Hero Member
  • *****
  • Posts: 14169
  • Probably until I exterminate Putin.
Re: Compiled file size query
« Reply #19 on: January 23, 2020, 04:54:52 pm »
That is not a real solution. It only saves storage space, not memory. It can also have side effects like out of memory.
« Last Edit: January 23, 2020, 04:56:52 pm by Thaddy »
Specialize a type, not a var.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Compiled file size query
« Reply #20 on: January 24, 2020, 07:54:42 am »
Primarily? NOT SIZE!

Packages are mainly to be able to compile parts of a program (e.g. a customer specific module) after the main program, without recompiling the original.
That's, what I'm talking about. It's not problem for open source applications, as they can always be recompiled. In case of closed source programs - plugins are the only solution.
To reduce the size of the compiled project I'm using UPX tool.

In my case the size passes from 11MB to 3MB

Regards
Luca
As UPX modifies application memory, it prevents pages from: 1) Being discarded instead of unloaded to swap 2) Being shared between application instances. It's ok to use it for small stand alone applications, but it's not ok to use it for big complex projects, as it can cause waste of memory.
« Last Edit: January 24, 2020, 07:57:45 am by Mr.Madguy »
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Compiled file size query
« Reply #21 on: January 24, 2020, 09:12:30 am »
As the LCL is currently statically linked into the application already this whole static binary would likely be larger than the static wxWidgets binary.
You will be suprized, but
Code: Bash  [Select][+][-]
  1. D:\wxWidgets-3.1.1\samples\minimal\gcc_mswu_32>dir
  2.  
  3. 2020-01-23  19:28         7 348 736 minimal.exe
  4. ...
  5.  
(yes, stripped), and this is much bigger than any of my Lazarus app (with much bigger functionality  8-)).
I suspect that Linux things are something like that.
*shrugs* The LCL can't be smartlinked as aggressively due to its architecture, but as marcov said the growth isn't as extreme if new functionality is used.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11353
  • FPC developer.
Re: Compiled file size query
« Reply #22 on: January 24, 2020, 09:49:32 am »
To reduce the size of the compiled project I'm using UPX tool.

In my case the size passes from 11MB to 3MB

And what exactly does this change really solve?

UPX is just another component that needs to be validated, and has known to cause problems (it doesn't support the full PE format, but only the part that is supported by GCC) and its binaries are more often flagged by antivirus software.

All problems that are IMHO bigger than the size. 11MB is still small on even a modest 128GB  SSD.

Thaddy

  • Hero Member
  • *****
  • Posts: 14169
  • Probably until I exterminate Putin.
Re: Compiled file size query
« Reply #23 on: January 24, 2020, 10:38:39 am »
AFAIK upx has been removed some years ago, while it was still a standard option in FreePascal. (and on my request)
Specialize a type, not a var.

lawman

  • New Member
  • *
  • Posts: 43
Re: Compiled file size query
« Reply #24 on: January 24, 2020, 12:58:31 pm »
when compiling, does lazarus only put the components used into the binary, or all of them?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11353
  • FPC developer.
Re: Compiled file size query
« Reply #25 on: January 24, 2020, 01:27:43 pm »
when compiling, does lazarus only put the components used into the binary, or all of them?

Roughly the same as Delphi, for details how smartlinking works, see this post: https://stackoverflow.com/questions/4519726/delphi-which-are-the-downsides-of-having-unused-units-listed-in-the-uses-clause/4519894#4519894

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: Compiled file size query
« Reply #26 on: January 24, 2020, 01:56:44 pm »
Why does a GTK2 simple hello world gui with one button and one label take 2.9mb size?

Same thing with Codeblocks wxwidgets gui takes 100k.
Thanks

A simple hello world program cannot show the power of the programming tool.

Long time ago, I wrote a simple stock control program for my friend who running a small shop. It was my first and 'real' program written using Lazarus. The program has basic stock control features: stock in/out/reject, basic reporting and printing features without any accounting calculations. The program only consists of 1 single binary, no dll and the file size is only 4,3 MB. On its first run it will automatically generate some dbf files. No installation headache, simple copy to your computer and run it. Backup is extremely easy, copy/paste the folder to your flashdrive.

After that, then I was sure that Lazarus is worth for my time.

Before I use Lazarus, I had a non-licensed copy of Delphi 7. I checked the price, it was something around $3000. I can't afford it for my hobby projects and I respected their license term. Luckily there was Lazarus. The early versions of Lazarus were buggy, but not now. Thank you Lazarus' team for making it so awesome.

 

TinyPortal © 2005-2018