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


in reply to Forking and sharing variables

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?