それはあなたに嘘をついていることに注意しmalloc(3)
てください-それは実際に一度にすべてのメモリを割り当てるのではなく、OSにそれを要求するだけで、OSはに嘘をつきますmalloc(3)
。これは完全に正常な動作であり、ほとんどの場合正常に機能します。/proc/sys/vm/overcommit_memory
inの説明にproc(5)
は、次の詳細が含まれています。
/proc/sys/vm/overcommit_memory
This file contains the kernel virtual memory
accounting mode. Values are:
0: heuristic overcommit (this is the default)
1: always overcommit, never check
2: always check, never overcommit
In mode 0, calls of mmap(2) with MAP_NORESERVE are not
checked, and the default check is very weak, leading
to the risk of getting a process "OOM-killed". Under
Linux 2.4 any nonzero value implies mode 1. In mode 2
(available since Linux 2.6), the total virtual address
space on the system is limited to (SS + RAM*(r/100)),
where SS is the size of the swap space, and RAM is the
size of the physical memory, and r is the contents of
the file /proc/sys/vm/overcommit_ratio.
Valgrindはそれほど派手になることはできません。実際には、プロセスに割り当てられた、初期化された、および初期化されていないメモリを追跡します。したがって、プロセス自体よりも多くのメモリが必要であり、メモリのオーバーコミットに対して同じ許容範囲はありません。
valgrindでプログラムを実行するために必要なメモリがどれだけ増えるかはわかりませんが、さらに数ギガバイトのスワップスペースを追加してみてください。を使用してファイルにゼロを書き込むことで新しいスワップファイルdd
を作成できます(スパースファイルは使用しないでください)。次にmkswap(8)
、ファイルを実行して初期化し、ファイル名を使用して実行swapon(8)
して、システムにスワップファイルとして使用するように指示します。 。