我尝试使用 shmget() 分配 22MB 的共享内存,但它以 errno ENOMEM 退出。top 输出的第一行看起来好像有足够的内存:
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.
该程序运行 OS X 版本 10.8.5。知道原因可能是什么吗?