Re: shmget from a Cocoa application
Re: shmget from a Cocoa application
- Subject: Re: shmget from a Cocoa application
- From: Alastair Houghton <email@hidden>
- Date: Fri, 13 Jul 2007 09:12:36 +0100
On 13 Jul 2007, at 08:13, Jay Reynolds Freeman wrote:
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".
This is the wrong list for this query; the problem is nothing to do
with Cocoa. You probably want the Darwin list.
Anyway, the answer to your question is that there is a limit on the
total amount of memory supplied by shmget() in the system, which is
probably why your app can't allocate memory. You probably,
therefore, don't want to use it.
Take a look at the POSIX function shm_open() instead; you use it with
mmap() (shm_open() just gives you a file descriptor; typically you
ftruncate() it to the required length, then mmap() the descriptor to
get it into your address space).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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