-   Programming (
-   -   Problem in allocating shared memory size more then 672 (

shashwat.gupta 05-08-2006 11:37 AM

Problem in allocating shared memory size more then 672
Hi there,

I am using Redhat Enterprise Linux 3. I am using it on 512 MB RAM . For some application I want shared memory up to 2.5 GB. I was just trying to get shared memory through simple program that uses shmget system call. for memory allocation. I changed the entry of shmmax with command echo "1073741824" >/proc/sys/kernel/shmmax

Then try to execute a program which allocate shared memory
sharedmemory.c as follows --
#include <sys/types.h>
#include <sys/ipc.h>

#include <sys/shm.h>
#include <errno.h>
#include <stdio.h>

#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>

int main(){

key_t key = 1311;

int m_shmid = shmget(key,1048576*1024,IPC_CREAT|0666);
/*trying to allocate memory size of 1GB */
printf("m_shmid value is %d", m_shmid);

/*some header file are extra pleasse do not mind*/

The shmid value comes out to be -1 surprisingly method works perfectly when I try to allocate the memory up to 688128*1024 bytes (That is 672 MB) I donot reason please tell me any thing I need to do make it work

I am executing all commands on root permission

graemef 05-08-2006 12:47 PM

Not really my area but how much swap do you have?

paulsm4 05-08-2006 01:00 PM

Try looking at your SHMMAX parameter:

shashwat.gupta - please don't cross-post. It's impolite ;-)

All times are GMT -5. The time now is 05:30 PM.