Jan E. Schotsman wrote:
> Hello all,
> If you're not on the beach maybe you can give me a little help.
> I need to implement shared memory between my application and a helper
> At first I tried CFMessageProts. This works, but if you transport huge
> amounts of data the data get all paged out and after a few GB I crash.
> Then I tred shmget and friends. This works, but I can get only 1-2 MB of
> memory this way. I need at least 8MB and I would prefer no limit atall.
> So now I am trying mapping a file but I can't get this to work.
> The following bare-bones XCode Carbon application crashes. Please tell
> me what is wrong.
As for the shmget and shmat services, did you use the sysctl command to
check the maximums set for the kernel.
Check the output of: sysctl -a | grep shm
the kern.sysv.shmmax parameter is the maximum size of a segment.
The following code tests the shm services - pass the size on the command
int main(int argc, char** argv)
int key = 0x1000;
if(argc != 2)
printf("Usage: shmtest <size>\n");
int size = atoi(argv);
if(size <= 0)
printf("Invalid size: %d\n", size);
id = shmget(key, size, IPC_CREAT|SHM_R|SHM_W);
if(key > 0)
sharedmem = shmat(id, 0, 0);
if(sharedmem != (void*)-1)
printf("Failed shmat - %d\n", errno);
shmctl(id, IPC_RMID, 0);
printf("Failed shmget - %d\n", errno);
} >> Stay informed about: Shared memory