Article View: aus.computers.linux
Article #57594Re: Do shared libraries save memory or disk space
From: Tyson Richard DOWD
Date: Thu, 12 Sep 1996 00:00
Date: Thu, 12 Sep 1996 00:00
45 lines
2471 bytes
2471 bytes
freemant@wr.com.au (Kent Tong) writes:
>john@nlc.net.au (John Saunders) wrote:
>>I'm after some info about shared libraries. In the case of a library X
>>X, if application A and B both use it, is there any memory use advantage
>>over making X shared instead of a link library? I know there is a disk
>>space advantage and suspect there may be a memory advantage. In the case
>>were process B is a child process of A that hasn't exec'ed, is there
>>any memory advantage?
>>If you want to know why I'm asking this. I have a HTTP server that can
>>fork dozens of child processes to handle requests. I want to know if I
>>can get better memory sharing by moving parts of the server into shared
>>libraries.
>The child process should just share its code pages with
>the parent process. This means using shared lib in this
>situation won't help you at all. It'd be a different story
>if they weren't the same program.
If you use vfork, it will do that. It's done by marking all the pages
of the parent process 'Copy-on-Write'. So you won't really use much
memory at all, until you exec, or start modifying data, when it will
copy just that page and keep going. So your memory usage will grow in
proportion to the pages written to, not the number of processes (but
the two are linked, of course ;-).
But I suspect that the Linux fork is vfork anyway (no evidence, just
seems silly not to do it this way - cost is low, and most programs just
fork and then exec anyway, so why bother copying all that stuff).
>---
>Kent Tong
>Freeman Installer ==> http://www.netnet.net/users/freeman/
--
Tyson Dowd # 4.1: Why doesn't this code work?
# a[i] = i++;
trd@cs.mu.oz.au # A: You didn't declare either i or a.
http://www.cs.mu.oz.au/~trd # -- The C-IAQ
Technical Details
Message-ID:
<518ap6$a2v@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<513nvh$2hv@nhj.nlc.net.au> <515cso$su7@metro.ucc.su.OZ.AU>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1103af,69c6938f9ae135ef X-Google-Attributes: gid1103af,public X-Google-Thread: 102983,69c6938f9ae135ef X-Google-Attributes: gid102983,public From: trd@murlibobo.cs.mu.OZ.AU (Tyson Richard DOWD) Subject: Re: Do shared libraries save memory or disk space Date: 1996/09/12 Message-ID: <518ap6$a2v@mulga.cs.mu.OZ.AU> X-Deja-AN: 180101618 distribution: inet references: <513nvh$2hv@nhj.nlc.net.au> <515cso$su7@metro.ucc.su.OZ.AU> organization: Comp Sci, University of Melbourne newsgroups: aus.computers.linux,comp.os.linux.misc