climateprediction.net home page
Fixing Error Code 6: Could not create shared memory region
Fixing Error Code 6: Could not create shared memory region
log in

Advanced search

Questions and Answers : Macintosh : Fixing Error Code 6: Could not create shared memory region

Author Message
Profile MikeMarsUK
Volunteer moderator
Avatar
Send message
Joined: 13 Jan 06
Posts: 1498
Credit: 13,504,741
RAC: 13,691
Message 29271 - Posted: 17 Jun 2007, 9:41:38 UTC
Last modified: 17 Jun 2007, 9:48:34 UTC

You may notice that some Macs have been crashing models with an Error Code 6 \"Could not create shared memory region\" error (as in the following example):

http://climateapps2.oucs.ox.ac.uk/cpdnboinc/result.php?resultid=6594856

Over Outcome Client error Client state Computing Exit status 6 (0x6) CPU time 0 stderr out <core_client_version>5.8.17</core_client_version> <![CDATA[ <message> process exited with code 6 (0x6) </message> <stderr_txt> shmget: No such file or directory shmget: Cannot allocate memory Could not create shared memory region 175095, 655060 Error in creating shared memory region! </stderr_txt> ]]>


The problem is that by default the Mac allocates only a small amount of shared memory segments. Each Boinc task requires one, and it is easy to run out. It is most likely to happen on high-end Mac Pro systems (with 4 or 8 cores), simply because they will be running more Boinc tasks.

It is easy to increase the amount of shared memory, which will resolve the problem.

The following is a quote from SPYHILL : Configuring Shared Memory on Mac OS X
Shared memory is a form of Inter-Process Communication (IPC). Separate programs running on the same computer are able to communicate with each other by reading from and writing to a commonly allocated memory block.

A good example of how this can be useful is provided by BOINC, the Berkeley Open Infrastructure for Network Computing, which is the software used by distributed computing projects such as SETI@Home and Einstein@Home. The BOINC Core Client is the main program which manages the execution of multiple application programs for the various BOINC projects. When the Core Client starts an application process it provides configuration information and communicates commands to the application via shared memory.

On a multi-processor Mac where the BOINC Core Client is configured to keep suspended processes in memory it is possible that an application program will fail because it cannot allocate shared memory.
...
You can view the shared memory settings on your Mac by opening the Terminal application (it is in the Applications -> Utilities folder) and giving the command

sysctl -A | grep shm
which should produce something like:
kern.sysv.shmmax: 4194304
kern.sysv.shmmin: 1
kern.sysv.shmmni: 32
kern.sysv.shmseg: 8
kern.sysv.shmall: 1024
...
To change the shared memory settings you also need to be able to give commands as the \"root\" user on your Mac. If you like, you can follow these instructions on How to Enable the root Account on Mac OS X. However, you can also simply log in as the \"Admin\" user, open up the Terminal application (it is in the Applications -> Utilities folder) and giving the command:

sudo emacs /etc/sysctl.conf
It is likely this file doesn\'t exist on your system, in which case an empty file will be created. Edit this file so that it contains the lines:

kern.sysv.shmmax=16777216
kern.sysv.shmmin=1
kern.sysv.shmmni=128
kern.sysv.shmseg=32
kern.sysv.shmall=4096

These settings increase the amount of shared memory to four (4) times the usual default.
These shared memory settings will be applied the next time the computer boots. You can verify the settings after the reboot using the \"sysctl -A\" command demonstrated above.



adempster has kindly experimented with this solution on his Mac, and it resolved the problem of climate models crashing.

This problem has been discussed elsewhere, see these threads for further reading:

BoincDev forum: Mac OS X: Can\'t destroy/create shared memory

BoincDev forum: Intel Mac shared memory issue

FinkProject: Shared Memory Regions on Darwin

Profile MikeMarsUK
Volunteer moderator
Avatar
Send message
Joined: 13 Jan 06
Posts: 1498
Credit: 13,504,741
RAC: 13,691
Message 29388 - Posted: 1 Jul 2007, 7:45:03 UTC
Last modified: 9 Sep 2007, 9:38:01 UTC


The Boinc manager has been updated to try to avoid these shared memory problems.

The changes are in the official release version 5.10.20 of the Boinc Manager (as well as in test versions from 5.10.10 onwards). This can be downloaded from http://boinc.berkeley.edu/download.php


For further information, see the following thread: (relevant extract provided).

http://boinc.berkeley.edu/dev/forum_thread.php?id=1871

\"Charlie Fenton\" wrote:
...

On the basis of these reports, I\'ve made major changes to the way that BOINC handles shared memory unavailability. It will no longer cause a computation error, and when all BOINC\'s available shared memory segments are in use, it will run only those applications which already have shared memory allocated (such as those left in memory because they haven\'t checkpointed.)

I expect to release this to alpha testing as version 5.10.10 later tonight. Please get a copy from the \"all versions\" download page and see if it helps.
...

I also discovered that BOINC was doing a poor job of cleaning up after itself when it quits, so it sometimes left orphaned shared memory segments in the system. While these did not count against the per-process limit (8 by default on the Mac) it did count against the system-wide limit (32 by default on the Mac.)

So if you quit and restart BOINC a few times, and especially if BOINC crashed a few times, it might be good to restart the computer.

The new version 5.10.10 does a much better job of cleaning up shared memory segments, even when being restarted after a crash. So this should not be a problem with 5.10.10.


____________
I'm a volunteer and my views are my own.
News and Announcements and FAQ

Questions and Answers : Macintosh : Fixing Error Code 6: Could not create shared memory region


Main page · Your account · Message boards


Copyright © 2017 climateprediction.net