HUGE Virtual Memory Usage

Tony Arnold tony.arnold at manchester.ac.uk
Thu Oct 6 18:34:32 UTC 2005


Matt,

On Thu, 2005-10-06 at 12:34 -0400, Matt Patterson wrote:

> Another question: If using a shared library requires it to be loaded
> into ram, and that means huge ram usage as I am seeing because the
> modules are large, would it not be more memory efficient (I know it
> wastes hard disk space) to simply statically link apps instead of
> dynamically. Then apps wouldnt have dependency issues and they would
> only load the necessary routines into memory? Of course there would be
> redundancy in memory because each app could load the same functions,
> but still.

There is clearly a trade off here and with a small number of
applications where each only uses a small number of routines from
libraries, you may get some gain, however, the shared library is
probably best in the long run.

You have to remember that it does not cost a great deal of resource to
have a large shared library in virtual address space. With the paging
algorithms in Linux only the pages of the library that get referenced,
ie., actually run or have data will ever get loaded into real memory.
And if the same page(s) of a shared library are used by more than one
application, it is only loaded once!

The other advantage of shared libs is that you do not have to re-link
all the applications that use it if it gets updated (mostly!), whereas
with statically linked apps you would. You could then end up with apps
linked against different versions of the library and then get
inconsistencies.

In fact Ian Murdoch's (the founder of Debian) idea to separate out
libraries from applications at the package level is partly what makes
the update process of Debian derived Linux systems so straight forward.

Regards,
Tony.
-- 
Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at manchester.ac.uk, H: http://www.man.ac.uk/Tony.Arnold




More information about the ubuntu-users mailing list