Fork () with Out of memory error

The parent process fails with errno = 12 (Out of memory) when it tries to unlock the child. The parent process runs on the Linux 3.0 kernel - SLES 11. At the time the child process was deployed, the parent process already used about 70% of the RAM (180 GB / 256 GB). Is there any workaround?

The application is written in C ++, compiled with g ++ 4.6.3.

+5
source share
2 answers

Your system might be preventing virtual memory from committing.

If this is prevented, virtual memory cannot be larger than the size of physical RAM + swap. If allowed, then virtual memory may be larger than RAM + swap.

, ( ) 2 * 180 ( , ).

, :

 echo 1 > /proc/sys/vm/overcommit_memory

, , . , , , .

man- proc (5) :

/proc/sys/vm/overcommit_memory

. : 0: overcommit ( ) 1: overcommit, 2: , overcommit

0 mmap (2) MAP_NORESERVE , "-". Linux 2.4 1. 2 ( Linux 2.6) (SS + RAM * (r/100)), SS - , r - /proc/sys/vm/overcommit _ratio.

: SLES

+9

fork -ing , copy-on-writing . fork (2) man page.

. ( ) $SWAPFILE

  dd if=/dev/zero of=$SWAPFILE bs=1M count=256000
  mkswap $SWAPFILE
  swapon $SWAPFILE

, , -, . mmap - - ( munmap - mmap - ) , , popen -ed shell, p2open - pipe -s (, à la poll), .

, , , , , ...

Linux.

PS.

fork gdb, , , GCC libbacktrace Wolf libbacktrace...

+1

All Articles