jryan has asked for the wisdom of the Perl Monks concerning the following question:

I have been using IPC::Shareable with some success to communicate across forked processes. However, when executing my program during a test run (during which no code dealing with the shared memory had been changed), my program stopped working. Completely. For no obvious reason. It gave me this error:
Could not create semaphore set: No space left on device at server.pl line 57
Line 57 assigns an annoymous array to an element of a IPC::Shareable tied hash. Previously (in roughly 70-100 previous test runs), there wasn't a problem. However, there is now. I have 80 megs of free memory, 5 gigs of hd space, killed every process running, and even slayed my account. If anyone has any incite to my problem (or can even point to some helpful documentation that has eluded me), I would be very greatful

-jryan
  • Comment on Problems with IPC::Shareable - Could not create semaphore set: No space left on device
  • Download Code

Replies are listed 'Best First'.
Grab your sysadmin
by Fletch (Bishop) on Oct 25, 2001 at 07:51 UTC

    Check what the manual page for the underlying semget(2) call on your OS is saying when it's returning ENOSPC. Many systems have a fixed number of semaphore sets (or a fixed overall number of semaphores) that might need to be tweaked by your sysadmin. It may also be that there's existing semaphores lying around that haven't been cleaned up (because something crashed, was sloppy about deallocating them) that you can use the ipcs and ipcrm commands to manually take care of.

Check IPC availability
by fokat (Deacon) on Oct 25, 2001 at 18:18 UTC
    You do not mention what OS are you in. Things like this can happen when you do not remove the IPC structures before exiting, leaving them behind.

    Many OSes have limits on the amount of shared memory, semaphores or message queues they can create. The limit is often unrelated to how large is the system. The combination of these things can be the problem.

    You can check this out by using the ipcs command, like in:

    [root@guess again]# ipcs ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status ------ Semaphore Arrays -------- key semid owner perms nsems status ------ Message Queues -------- key msqid owner perms used-bytes messages
    The above example shows an empty IPC table, which is the state that your program should leave your machine after running. The output of the command can be different, so be sure to check your docs on this one.

    If you find dangling IPC structures after your program is done, you can manually delete them using the ipcrm command. Again, check your manual on how to do this.

    Good luck.

Re: Problems with IPC::Shareable - Could not create semaphore set: No space left on device
by MZSanford (Curate) on Oct 25, 2001 at 18:30 UTC
    I have seen this, on occasion, on systems that do not clear semaphore resources. I could suggest rebooting, which will force them, but thats not the nicest way. Did fokat's ipcs solution provide anything ? Usually the ipcs command shows any open shared memory ... if that shows all of the memory you have used, then you will need to clear them (using ipcrm)
    i had a memory leak once, and it ruined my favorite shirt.