If you happen to be on Linux/Unix, and you happen to be running all the daemons on the same server, and they all happen to be forked from the same parent process, and they all happen to load a bunch of the same data, then you may be able to share memory by loading the data before the fork. This reduces the total memory footprint on the system.

I use this practice to good effect with mod_perl processes by loading up dozens of megabytes of cached data in the parent process initialization before Apache forks off the children to handle the incoming HTTP requests. Even though there are 30 child processes, they all share the same memory when accessing the cached data.

Note that Linux/Unix fork shares the memory until one of the processes decides to write to it at which point the operating system copies the data into a new block and lets the process muck in its own sandbox without affecting the other processes which still see the old copy of the data.

If the above assumptions do not happen to apply to your situation, I recommend you look seriously at the cost of developer time to optimize the memory vs. the cost to purchase more memory.

Perl is notoriously memory hungry.

-- Eric Hammond


In reply to Re: gigantic daemons by esh
in thread gigantic daemons by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.