简体   繁体   中英

shmget return ENOMEM with 12GB free

I try to allocate 22MB of shared memory using shmget(), but it exits with errno ENOMEM. The first lines of top's output look as if there was enough memory:

Processes: 114 total, 4 running, 110 sleeping, 579 threads
Load Avg: 0.50, 0.42, 0.35  CPU usage: 0.24% user, 0.60% sys, 99.15% idle
SharedLibs: 17M resident, 5356K data, 0B linkedit.
MemRegions: 20375 total, 1361M resident, 59M private, 1176M shared.
PhysMem: 1487M wired, 1887M active, 576M inactive, 3950M used, 12G free.
VM: 286G vsize, 1052M framework vsize, 123007(0) pageins, 0(0) pageouts.

The program runs with OS X version 10.8.5. Any idea what the cause might be?

The following sysctl variables affect shared memory: kern.sysv.shmmax, kern.sysv.shmmin, kern.sysv.shmmni, kern.sysv.shmseg, kern.sysv.shmall. Here kern.sysv.shmall should generally be set to at lease kern.sysv.shmmax divided by 4096.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM