douhu1990 2017-02-03 01:08
浏览 60

如果使用PHP运行编译,则无法分配内存

I'm currently working on a PHP script that is running the compilation of Passenger by using this command:

passenger-install-apache2-module --auto

If I run the command in SSH, it work fine, but when I start it with exec() from PHP, I'm getting "virtual memory exhausted: Cannot allocate memory".

c++ -o buildout/support-binaries/CoreMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAVE_ACCEPT4 -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -std=gnu++11 -Wno-unused-local-typedefs -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<hash_fun.h>" -c src/agent/Core/CoreMain.cpp
virtual memory exhausted: Cannot allocate memory
rake aborted!
Command failed with status (1): [c++ -o buildout/support-binaries/CoreMain.o  -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -ggdb -DHAS_ALLOCA_H -DHAVE_ACCEPT4 -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -std=gnu++11 -Wno-unused-local-typedefs -DHASH_NAMESPACE="__gnu_cxx" -DHASH_MAP_HEADER="<hash_map>" -DHASH_MAP_CLASS="hash_map" -DHASH_FUN_H="<hash_fun.h>" -c src/agent/Core/CoreMain.cpp]
/usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.2/build/support/cplusplus.rb:52:in `run_compiler'
/usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.2/build/support/cplusplus.rb:102:in `compile_cxx'
/usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.2/build/support/cplusplus.rb:160:in `block in define_cxx_object_compilation_task'
Tasks: TOP => apache2 => buildout/support-binaries/PassengerAgent => buildout/support-binaries/CoreMain.o
(See full trace by running task with --trace)

I've tryed on servers with up to 8GB of RAM. I'm not getting any OOM in /var/log/messages so I don't think the memory is the issue.

Any idea why I'm getting this error when running from exec() only?

  • 写回答

1条回答 默认 最新

  • dongyun4010 2017-02-09 13:47
    关注

    I finally found the issue. My PHP script is running as a WHM (cPanel) plugin and it seem that WHM setting a ulimit before running the script. Since the script run as root, I only had to modify the ulimit before running the bash.

    exec("ulimit -m unlimited -v unlimited; bash myscript.sh");
    
    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条