[KLUG Programming] Shared libraries & memory usage.

Robert G. Brown programming@kalamazoolinux.org
Mon, 14 Jul 2003 21:45:30 -0400


On 14 Jul 2003 19:57:54 -0400, Adam Williams <awilliam@whitemice.org> wrote:

>> I haven't investigated this too much but what I do know is that if you're 
>> using libdl to open a shared library you get the option to resolve symbols 
>> all at once or resolve new symbols as they are called upon.  
>> This would lead me to believe that you should be able to pick whether or
>> not the entire library is loaded, at least for libraries loaded 
>> dynamically at runtime.
>
>I believe (and poking around in /proc seems to validate this) that
>library files (by default anyway) are openned as memory mapped files. 
>Thus only used sections should get allocated to physical pages.

This is a clever technique, but it's not quite the same as "control". The
file is being opened and potentially it can all get read into memory, we're 
simply uing memory mapping as a facility to minimize that, so that what ends 
up resident is what ends up getting used (most, last)...

I think the spirit of bruces question was along the lines of something more 
formal than demand paging.


On Mon, 14 Jul 2003 18:54:25 -0400, Erik Gillespie <rattles@yakko.cs.wmich.edu> wrote:

>I haven't investigated this too much but what I do know is that if you're 
>using libdl to open a shared library you get the option to resolve symbols 
>all at once or resolve new symbols as they are called upon.  
That's interesting; is it your understanding that the word "resolve" means
the same as "load"? 

>This would lead me to believe that you should be able to pick whether or
>not the entire library is loaded, at least for libraries loaded 
>dynamically at runtime.
Yes, some dynamic loaders support this, current memory/time economics put
things very much against "object-at-a-time" loading.

							Regards,
							---> RGB <---