[fpc-devel] Dnamic packages support

Michael Van Canneyt michael at freepascal.org
Sat Nov 3 20:13:24 CET 2007



On Sat, 3 Nov 2007, Daniƫl Mantione wrote:

> 
> 
> Op Sat, 3 Nov 2007, schreef Michael Van Canneyt:
> 
> > 
> > > - memory footprint of programs increase significantly since no
> > > smartlinking is possible, I created once a pure shared linked lazarus:
> > > it depended on 50 MB of shared libs.
> > 
> > Disk footprint may be higher, but memory footprint is definitely lower.
> > I did extensive testing on that.
> 
> The memory footprint can only be lower if multiple applications are in 
> memory that can use the same packages.

You forget something, see below.

> 
> Even then, there will only be savings if the amount of code that can be 
> smartlinked is small.
> 
> Example: Let's say an LCL package is 10MB. 2 applications are 2MB when 
> smartlinked, and 100kb when linked against the package. (The heap can be 
> ignored in this discussion because its memory usage does not differ 
> depending on packages being used.)

This is wrong for plugins, see below.

> 
> Memory use with packages:     10MB+2*100KB = 10,2MB.
> Memory use with smartlinking: 2*2MB        =  4MB

First of all, we would be stupid to create a single LCL package. 
We should divide it into various packages grouping units 
according to functionality. Even Borland realized this eventually.
Secondly, your quoted sizes are simply bogus; This is not a valid 
argument for a discussion.

But that is beside the point.

I agree with you that for a single app, using packages is a bad thing for 
memory usage. No discussion there.

But the gain is not there. The gain I mentioned comes when using plugins.

With DLLs plugins, each DLL will of necessity have a lot of common code,
loaded into memory with each plugin. With packages, all code is in memory
only once.

Then, you are only considering code size. This is not enough. I am also 
considering heap size.  With DLLs, each DLL will of necessity have a lot 
of common data structures in memory, copied in each plugin. 
You would be surprised at the size of this. For a system with 100ds 
of interfaces, this can become a big amount.

Using packages for plugins, the code will be there only once, and the common
data structures in memory will be there only once. This is the gain I was 
talking about. It exists only for a plugin system, and when compared to a 
plugin system based on DLLs. 

Michael.


More information about the fpc-devel mailing list