Discussion:
shmget fails -- size limit?
Chris Scharver
2002-09-20 17:28:06 UTC
Permalink
Hello,

I am working on porting a UNIX library to OS X, and the library depends
heavily on the use of SysV IPC shared memory and semaphores. Calls to
shmget() fail running on 10.2, and the only error I received was an
invalid argument error. I did some more tracking and determined that
there appears to be a size limit on just how much shared memory can be
allocated. It seems quite minimal, as my application only requests
about 10MB. Trying to call shmget() with much smaller sizes (1-2MB)
works okay.

It looks like I'll have to dive into some OS-specific memory details.
I'm not really sure where to get started since I had hoped that the new
SysV and IPC support in 10.2 would make things relatively easy. I need
to keep this as low-level as possible while trying to maintain as much
consistency with other platforms (namely IRIX, Linux, HP, and Sun).

Also, how can I try to clean up any shared memory segments that are
left around? There doesn't seem to be anything like ipcs or ipcrm
available. Any help or pointers in the right direction would be much
appreciated!

Thanks,
Chris
Gerd Knops
2002-09-21 02:05:00 UTC
Permalink
Post by Chris Scharver
Hello,
I am working on porting a UNIX library to OS X, and the library
depends heavily on the use of SysV IPC shared memory and semaphores.
Calls to shmget() fail running on 10.2, and the only error I received
was an invalid argument error. I did some more tracking and determined
that there appears to be a size limit on just how much shared memory
can be allocated. It seems quite minimal, as my application only
requests about 10MB. Trying to call shmget() with much smaller sizes
(1-2MB) works okay.
Don't know much about this, but check out sysctl (in a terminal
window). sysctl -a shows (amongst other things) 'kern.sysv.shmmax:
4194304', which would seem to indicate that by default about 4MB are
available.

Gerd
Post by Chris Scharver
It looks like I'll have to dive into some OS-specific memory details.
I'm not really sure where to get started since I had hoped that the
new SysV and IPC support in 10.2 would make things relatively easy. I
need to keep this as low-level as possible while trying to maintain as
much consistency with other platforms (namely IRIX, Linux, HP, and
Sun).
Also, how can I try to clean up any shared memory segments that are
left around? There doesn't seem to be anything like ipcs or ipcrm
available. Any help or pointers in the right direction would be much
appreciated!
Thanks,
Chris
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Loading...