Ok, a couple of things I ran into. First, you went back to using 'data' as the glue for IPC::Shareable. If I'm not mistaken, this would cause a problem if you had more than one instance of this program running, because they would try to access the same shared memory segment. That's why I was using the pid of the process as the glue.

Also, from what I understand, at the end of the program you need to call IPC::Shareable->clean_up or the shared memory segment persists after the program ends, which is probably not desirable.

The last thing, which is one I couldn't get past, is that I seem to be running out of memory when creating the tied %mxs hash when using your method of defining it. It doesn't happen on a small list, but when I tried it on a list of 200 addresses I get:

IPC::Shareable::SharedMem: shmget: No space left on device at /usr/lib/perl5/site_perl/5.005/IPC/Shareable.pm line 446 Could not create shared memory segment: No space left on device at ./mx.pl line 39
So I added  size => 8000000 to %options and that just led me to plain old Out of memory!

I can't see why it should take more than 8 megabytes of memory to store MX servers for 200 domains. It didn't do this in my example code. But I don't see anything radically different about defining the %mxs hash ahead of time that would cause this.

Any ideas?


In reply to Re: Forking and sharing variables by httptech
in thread Forking and sharing variables by httptech

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.