in reply to Re: Perl vs. Shell Script
in thread Perl vs. Shell Script

...perl takes less than twice the memory of bash.

I suppose it depends on the system and shell, but aren't shell processes often kept in shared memory, and so additional shell processes would take little or no additional memory? I remember reading on some man page that you usually may as well spawn another process rather than use 'exec' for this (among other) reason(s).

Replies are listed 'Best First'.
Re: Perl vs. Shell Script
by Abigail-II (Bishop) on Jul 01, 2002 at 11:15 UTC
    I do not know what you mean. "shared memory" is the common term used if processes share part of their memory - to exchange data. I've never heard of shells communicating with utilities using shared memory - for this to work shells and utilities need to cooperate.

    I guess you mean something else, but I don't know what. It's also unclear what you mean by "spawning" a process. I think most people would consider "fork + exec" to be "spawning" (assuming we're talking Unix), but since you want to do something else than "exec", it's not a typical "fork + exec" you are referring to.

    Under UNIX, there is just one way of creating a new process, and that's by using "fork". And there's only one way to start a different program, and that's by using a member of the exec family.

    Abigail

      I think he's referring to the fact that the shell's code segment will be shared, so the OS won't have to load any new code to start a shell process. Of course, if you use Perl enough, its code should already be in memory as well...

      /s

        Yeah, that's what I meant (shared code segments that is...hey, its in memory, its shared, if that's an incorrect usage of the term 'shared memory', then I apologize) :-)

        When I spout off half remembered ideas, I do try to label them as such, and even though I don't always know what I'm talking about, someone is able to figure it out and (re)fill in the (wrongly filled in) blanks...

        And to Abigail-II, by 'exec' I meant exec w/o the fork (like in perl's exec as opposed to the system function, or a shell exec command).