2

我有 64 位 Linux 机器(Intel Xeon L5410 @ 2.33GHz)。

**meminfo:**
MemTotal:     24672736 kB 
MemFree:        145372 kB 
Buffers:        181896 kB 
Cached:       22004648 kB 
SwapCached:     195072 kB 
Active:        9761028 kB 
Inactive:     13964532 kB 
HighTotal:           0 kB 
HighFree:            0 kB 
LowTotal:     24672736 kB 
LowFree:        145372 kB 
SwapTotal:    17414452 kB 
SwapFree:     15618852 kB 
Dirty:         2125148 kB 
Writeback:           0 kB 
AnonPages:     1358396 kB 
Mapped:        1069632 kB 
Slab:           699464 kB 
CommitLimit:  29750820 kB 
Committed_AS:  9236252 kB 
PageTables:      38620 kB 
VmallocTotal: 34359738367 kB 
VmallocUsed:     17272 kB 
VmallocChunk: 34359718843 kB 
HugePages_Total:     0 
HugePages_Free:      0 
HugePages_Rsvd:      0 
Hugepagesize:     2048 kB 

**Also the shm details are:**
shmall                2097152 
shmmax                3294967296 
shmmni                4096 

我正在尝试创建 2 GB 以上的共享内存,shmget 成功,但后来发生核心转储,并出现无法访问内存的错误。虽然低于 2GB 的共享内存工作得非常好。我能够找到任何正当理由,因为我的 shmmax 值约为 3GB

4

1 回答 1

2

the maximum shm memory size is available thru /proc/sys/kernel/shmmax and you could write into that pseudo-file to change it. It probably cannot be raised above some portion (e.g. half) of physical RAM. Perhaps some kernel configuration can change that.

You can also share memory with the mmap syscall with MAP_SHARED flag.

于 2012-06-12T05:49:10.063 回答