Error in allocating shared memory
I am trying to allocate a shared memory of size 64B. But the compiler throws error when i give a size of more than 27.. How to solve this problem. I am using gcc compiler. I am running the program on a server.
This is the code i used.
shmid=(shmget(key,size,IPC_CREAT | 0666)); // size is defined as 64
I am getting an error saying memory allocation failed. But for size under 开发者_开发问答27 it works fine
Don't use SysV shared memory -- the interface is seriously awful, and has a number of huge drawbacks (e.g, there are tight limits on how much you can use, and it has to be cleaned up manually if your application crashes). If you need shared memory, use mmap()
.
精彩评论