[Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)
Florian Klaempfl
florian at freepascal.org
Wed Apr 8 20:39:46 CEST 2009
Alexey S. Smirnov schrieb:
> Martin Friebe пишет:
>> Is this documented somewhere? I can't follow the logic anyway, the scope
>> how much my code uses of another unit can not be predicted, simply by
>> where I include the other code?
>>
>> Actually, I do believe I have seen examples where code form units used
>> in the interface was successfully smart-linked.
>>
>> However there is a differentiation what can be smart linked and what
>> not. If a class has RTTI information, then methods from it can not be
>> removed by smart-linking. Classes with RTTI (afaik) are either included
>> as a whole or not at all. (And that make sense, because RTTI allows to
>> access any method by finding it from a resource or literal string; which
>> are both not parsed by the compiler, and therefore not determinable)
>>
>> Best Regards
>> Martin
>>
>>
>
> May the problem will become understandable, if we will do a little
> experiment. So. Let's test the Interface/Implementation Uses sections of
> /lazarus/lcl/graphics.pp. This section for Lazarus 0.9.26 was that:
> |interface
> uses
> SysUtils, Math, Types, Classes, Contnrs, FPCAdds,
> FileUtil,
> FPImgCmn, FPImage, FPCanvas,
> FPReadPNG, FPWritePNG, PNGComn, // png support
> FPReadBMP, FPWriteBMP, // bmp support
> FPReadPNM, FPWritePNM, // png support
> FPReadJpeg, FPWriteJpeg, // jpg support
> IntfGraphics,
> AvgLvlTree,
> LCLStrConsts, LCLType, LCLProc, LMessages, LCLIntf, LResources,
> LCLResCache,
> GraphType, IcnsTypes, GraphMath, InterfaceBase, WSReferences;|
> |
> implementation
> uses
> SyncObjs;|
>
> It was cleanup by me and now looks like that:
> |Interface
> uses
> SysUtils, Types, Classes,
> FPImgCmn, FPImage, FPCanvas,
> FPReadJpeg, FPWriteJpeg, // jpg support
> IntfGraphics, AvgLvlTree,
> LCLType, LMessages, LResources,LCLResCache,
> GraphType, IcnsTypes, GraphMath, InterfaceBase, WSReferences;|
>
>
> |implementation
> uses
> {FPReadPNG,} FPWritePNG, PNGComn, // png support
> {FPReadBMP,} FPWriteBMP, // bmp support
> FPReadPNM, FPWritePNM, // png support
> LCLStrConsts,LCLProc,LCLIntf,
> FileUtil, FPCAdds, Math,
> SyncObjs;
>
> |So, previously we have 33 Units mentioned in Interface section and 1 in
> Implementation section. After cleanup we have 19 Units in Interface
> section and 12 in Implementation. 3 Units from Interface section was
> completely removed. ;)
>
> Both Lazarus and all connected apps and projects are working fine with
> this cleanup. And if you do the same thing - you will see that that
> size of Lazarus will be 15-20 KB less. May be - because of such
> optimization, may be - because of removing unused units from *Interface*
> section....
This could be simply the influence of a different memory layout of the exe.
More information about the Lazarus
mailing list