我有64位REHL linux,Linux Linux ipms-sol1 2.6.32-71.el6.x86_64#1 SMP x86_64 x86_64 x86_64 GNU / Linux
RAM大小= ~38GB
我在/etc/sysctl.conf和amp;中更改了默认共享内存限制,如下所示:在内存中加载已更改的文件为sysctl -p
kernel.shmmni = 81474836
kernel.shmmax = 32212254720
kernel.shmall = 7864320
仅仅为了实验,我已经将shmmax大小更改为32GB,并尝试使用shmget()在代码中分配10GB,如下所示,但是单次拍摄无法获得10GB的共享内存,但是当我减少对共享空间的需求时8GB它是否能成功解决我可能出错的地方?
#include
#include
#include
#include
#define SHMSZ 10737418240
main()
{
char c;
int shmspaceid;
key_t key;
char *shm, *s;
struct shmid_ds shmid;
key = 5678;
fprintf(stderr,"Changed code\n");
if ((shmspaceid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
fprintf(stderr,"ERROR memory allocation failed\n");
return 1;
}
shmctl(shmspaceid, IPC_RMID, &shmid);
return 0;
}
此致
人士Himanshu