http://www.perlmonks.org?node_id=532911


in reply to Forking server for ssh tunnels

I was just building perl5.8.8 today and realized someone should have mentioned that you can make a "shared so" perl, which would significantly reduce the memory usage. My (typical) static perl is a little over 1 meg. If you build a "shared perl so lib", your Perl instances will probably be under 100k each, and all share 1 perl.so lib.

When you build Perl, you are asked if you want to do this. Although salva's advice of examining how you are opening ssh is probably important.


I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Forking server for ssh tunnels
by tinypig (Beadle) on Feb 26, 2006 at 20:57 UTC
    Ah, that is fantastic! I had forgotten that was one of the things I was meaning to look into. Based on what I'm seeing, I do not think we have it configured that way. Thanks for the suggestion. ++
Re^2: Forking server for ssh tunnels
by salva (Canon) on Feb 26, 2006 at 22:36 UTC
    Well, not really, modern operating systems do not clone the full memory image when forking but use a copy-on-write machanism, so they would share the perl binary code and most of the heap data anyway.

    I think, that even if you run the same process several times, the OS will not use new memory for the additional copies becauses it mmaps the executable.

    Compiling perl as a dynamic library is only useful if you are compiling it to build different executables, for instance, perl and Apache+mod_perl.