當linux 2.6.37.6上的大小> 1GB時,我的mmap失敗,errno 12失敗。mmap> 1GB失敗,errno 12
任何想法?我有64GB的RAM
# swapon -s
Filename Type Size Used Priority
/dev/sda1 partition 65537160 0 -1
和
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 495694
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 495694
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
編輯:添加UNAME -a
#[email protected]:~# uname -a
Linux maverick-5 2.6.37.6 #5 SMP Fri Feb 14 16:21:40 PST 2014 x86_64 GNU/Linux
編輯:添加免費
#free
total used free shared buffers cached
Mem: 63459224 317692 63141532 0 25800 36280
-/+ buffers/cache: 255612 63203612
Swap: 65537160 0 65537160
編輯:它是一種具有64GB RAM的64位系統:
# cat /proc/meminfo
MemTotal: 63459224 kB ...
編輯:添加MMAP代碼
...
*fd = open(file_path, O_RDWR, 0644);
if (*fd==-1){
printf("open file failed \n");
exit();
}
system("ulimit -m -v");
mem = mmap(0,0x80000000,PROT_READ|PROT_WRITE,MAP_NORESERVE|MAP_PRIVATE,*fd,0);
if (mem == MAP_FAILED){
printf("map failed failed %d %d\n", errno, mem);
exit();
}
你可以顯示你的'mmap'調用以及你傳遞給它的標誌嗎? – Joe
32位或64位系統?你有1GB的地址空間嗎? –
/dev/sda1是交換分區,64 GB是交換大小,但不是RAM。請運行'uname -a'和'free'來提供問題的更多細節;也發佈你的程序的代碼。 – osgx