shmget from a Cocoa application
shmget from a Cocoa application
- Subject: shmget from a Cocoa application
- From: Jay Reynolds Freeman <email@hidden>
- Date: Fri, 13 Jul 2007 00:13:06 -0700
I am trying to use "shmget" and its friends within
Cocoa applications, and am having trouble. I am posting
here because I suspect the problem may have to do with
how Cocoa initializes and/or uses malloc (which I understand
is at the root of most Cocoa run-time memory allocation).
I am presently running on a late-model Macbook with
OS X 10.4.10, using XCode 2.4.1.
I have a call to shmget embedded within a substantial
Cocoa application, which looks more or less like this:
smid_foo = shmget( 42, memory_wanted, IPC_CREAT | 0600 );
This is the first and only call to shmget, so the shared
memory should not yet exist. The app builds with no
errors or warnings.
When memory_wanted is a little greater than 10 MByte, the
call fails, and perror( 0 ) prints "Invalid argument".
When the value is about 1 MByte, it also fails; the error message is
"Cannot allocate memory". (The actual values of memory_wanted
are exact multiples of 4096, which I think is the Macintosh
page size).
A little net.research suggested that the file /etc/rc
contained relevant initialization information, so I report that
grep shm /etc/rc yields (reformatted to shorten lines)
sysctl -w kern.sysv.shmmax=4194304 kern.sysv.shmmin=1
kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024
though Apple's documentation (e.g., man sysctl) isn't
very helpful telling what these parameters mean.
I'd be happy to take this to another group if it is appropriate,
but high on my list of suspicions is that the initialization of
malloc has somehow reserved all unused address space for itself,
so that whatever it is that allocates shared memory cannot
operate, and how malloc is set up and used by Cocoa might be
a Cocoa topic. (I haven't found much of use on this subject
in the XCode documentation.)
Any suggestions? Thanks.
-- Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden