Return mmap cannot allocate memory, although enough

I am doing a pressure test with leveldb.

In util/env_poisx.cc : NewRandomAccessFile()

 void* base = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); 

after entering 3 million data (each 100 thousand). Errno says Cannot allocate memory .

why?

More details:

top:

  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19794 root 20 0 290g 4.9g 4.7g S 98.6 7.8 2348:00 ldb 

free -m:

  total used free shared buffers cached Mem: 64350 60623 3726 0 179 59353 -/+ buffers/cache: 1090 63259 Swap: 996 0 996 

ulimit -a:

 core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited pending signals (-i) 1024 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 10240 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 530432 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited 

Sysctl:

 vm.max_map_count = 300000 kernel.shmmni = 8092 kernel.shmall = 4194304 kernel.shmmax = 2147483648 
+4
source share
1 answer

man mmap:

"ENOMEM No memory, or the maximum number of process mappings will be exceeded.

When you write "3 million data (each 100k)", it seems to be related to vm.max_map_count 300000. Try changing this limit if you have enough memory.

Please give / proc / [pid] / maps | wc -l when an error occurs

0
source

Source: https://habr.com/ru/post/1437100/


All Articles