允许进程使用超过 4GB 的 RAM

Allowing a process to use more than 4GB RAM

我是 运行 64 位 Ubuntu 12.04,配备 8GB 内存。我写了一个 C++ 程序,我在 gcc 中使用 -m64(强制 64 位可执行文件)标志编译。我检查了生成的可执行文件确实是 64 位的。

但是,该进程最多使用 4GB RAM。我怎样才能让它使用更多?

编辑:ulimit -a

的输出
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) 62900

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) 62900

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

编辑 2:link 到 dstat -cdgms --vm

的输出

https://www.dropbox.com/s/927s5x6v4bhp4qs/dstat_log.xlsx?dl=0

据我所知,添加 -m64 编译标志(强制 64 位可执行文件)实际上解决了我最初的问题(应用程序崩溃),随后的巧合是我的应用程序实际上只需要超过 4GB 的内存(32 位可执行文件的限制)它在系统监视器中显示为 4GB 平面。感谢所有做出贡献的人,评论中有很多内容可能有助于人们尝试诊断类似问题。