Recent

Author Topic: Decrease the size of the executable of Lazarus  (Read 14825 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki
Re: Decrease the size of the executable of Lazarus
« Reply #15 on: August 03, 2015, 04:08:38 pm »
1) write your own component streaming / get rid of lfm and RTTI.
Anything that has RTTI (including anything with "published" properties) can not be smart linked away.
If a component has a property XYZ that pulls in a lot of code, but you never access it, then you not need the code. But if it is published it can be accessed via RTTI, which is not detectable at compile time, and therefore the code must go into your exe.

Current components using lfm use RTTI. Afaik FPGUI does not, it constructs all components in code. (Label1:= TLabel.Create(Form1); Label1.Parent:=Form...)

You can build your LCL apps using the same construct in code approach. And while the IDE must have RTTI, you could compile your own apps without (including recompiling LCL without. (At least in theory, not sure if in real live there would be added pitfalls).
Also not sure how much this saves. (I wouldn't expect to much. Well if all you do is an empty form, it might be a lot, but for any app with a mix of visual components the saving will be less)


2) Included units with initialization.
There is more code pulled into your app, which you do not necessarily need.
E.g. the graphic unit pulls in decoders for different formats (because components that use graphics (e.g. icons) in published properties might use png, or gif, or jpg or ...).
Again the compile can not know what you need. So for building apps fully automated with a wysiswyg designer, that is required.
But if you know what you do not need, you can edit those units (recompile them) and get rid of what you do not use.
I tried that once for some image formats, it saved about 100kb. Not very much. So hardly worth it for the majority of cases.


Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Decrease the size of the executable of Lazarus
« Reply #16 on: August 03, 2015, 06:36:36 pm »
I would place my bets on Nikolay :-)

Not seen much activity lately, that's why I picked it up. It is frankly not a priority. KOL itself is.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Decrease the size of the executable of Lazarus
« Reply #17 on: August 03, 2015, 08:04:32 pm »
I would place my bets on Nikolay :-)

Not seen much activity lately, that's why I picked it up. It is frankly not a priority. KOL itself is.

I tried, but it was like 13kb for a hello world. But maybe the snapshot was not smartlinking. I can recall I've seen 10kb tetrisen (which I usually use instead of hello world because it does something real)

 

TinyPortal © 2005-2018