Shared libraries are not necessary

Masataka Ohta mohta at necom830.cc.titech.ac.jp
Thu May 30 22:14:25 AEST 1991


Now, perhaps, it is time to show that shared libraries often increase
memory consumption.

If, as if often the case, we are running only one X applications, you
lose.

In article <4757 at skye.ed.ac.uk> richard at aiai.UUCP (Richard Tobin) writes:

>bute% ls -l xvserver*
>-rwxr-xr-x  1 richard    139264 May 22 21:28 xvserver*
>-rwxr-xr-x  1 richard   1286144 Mar 11 18:01 xvserver.static*
>bute% size xvserver*
>text    data    bss     dec     hex
>32768   8192    5360    46320   b4f0    xvserver
>942080  131072  16376   1089528 109ff8  xvserver.static

>How much is really shared?  Obviously it depends on what other programs
>are being run.  But we might well run several different xview programs
>simultaneously, and the saving in disk space is also substantial.

I asked Richard the size of library shared. And lines below are his reply:

:bute% ldd winserver/xvserver
:        -lxview.3 => /usr/bute/local/lib/libxview.so.3.0
:        -lolgx.3 => /usr/bute/local/lib/libolgx.so.3.0
:        -lX11.4 => /usr/bute/local/lib/libX11.so.4.2
:        -lc.1 => /usr/lib/libc.so.1.5
:
:bute% ls -l /usr/local/lib/lib{xview,olgx,X11}.so* /usr/lib/libc.so*
:-rwxr-xr-x  1 root       516096 Feb  8  1990 /usr/lib/libc.so.1.5*
:-rw-rw-r--  1 richard    229376 Jan 18  1990 /usr/local/lib/libX11.so.4.2
:-rwxr-xr-x  1 richard     57344 Jan 30 15:23 /usr/local/lib/libolgx.so.3.0*
:-rwxr-xr-x  1 richard   1040384 Jan 30 15:25 /usr/local/lib/libxview.so.3.0*
:bute% size /usr/local/lib/lib{xview,olgx,X11}.so* /usr/lib/libc.so*
:text    data    bss     dec     hex
:868352  73728   2544    944624  e69f0   /usr/local/lib/libxview.so.3.0
:40960   8192    0       49152   c000    /usr/local/lib/libolgx.so.3.0
:180224  24576   3584    208384  32e00   /usr/local/lib/libX11.so.4.2
:442368  16384   0       458752  70000   /usr/lib/libc.so.1.5

Thank you, Richard.

According to his data, total text space required for xvserver is:

	940Kbytes without shared libraries

and

	1560Kbytes with shared libraries.

Though not all functions in 1.56Mbytes are actually called, most pages
are swapped in if at least one function in the same page is called.

Of course, libc is shared with other system processes, and if we are
running other X clients, more is shared.

But, what matters here is the size of the working set. Thus, if all other
processes are inactive, there memory consumption is very small.

Memory consumption is determined by the working sets of active processes.

So, for example, as is often the case with personal workstations, if
users are concentrated on xvserver only, memory is wasted.

To save memory with shared libraries, we must running two or more similar
(that is, sharing most libraries) but not exactly same programs.

It may sometimes true with large server type machine shared by many people.
But, then, the machine is running many programs and, because of text
sharing, data size tends to dominate the memory consumption.

The example above is of xvserver (according to Richard, it is a graphical
front-end to prolog), but the same holds for a very common type of X users.

That is, if a user only uses multiple xterms or he concentate only on
a drawing tool, only active processes are xterms, thus memory is wasted.

							Masataka Ohta



More information about the Comp.unix.internals mailing list