linux – 无法删除PHP脚本的内存使用限制
情况
我遇到PHP脚本的问题,收到以下错误消息: 致命错误:969行/path/to/piwik/core/DataTable.php内存不足(分配359923712)(试图分配72个字节) 我正在运行的脚本是:/path/to/piwik/misc/cron/archive.sh 我假设数字是字节,这意味着总数约为360MB. 出于所有意图和目的,我已经将服务器上的内存限制增加到360MB以上,但这是一致错误的数字(给出或取一个字节). 请注意:这个问题不是关于修复脚本中的内存泄漏,也不是为什么脚本本身使用了这么多内存.该脚本是Piwik归档过程的一部分,所以我不能只修复任何内存泄漏等.有关此脚本的更多信息以及为什么我增加内存限制,请参阅“How to setup auto archiving” 这个问题 鉴于脚本试图使用超过360MB的内存,我无法改变,为什么我似乎无法增加服务器上的php可用内存量? 6月23日更新:请参阅“我尝试过的内容”> “增加Linux的每个进程内存限制”下面的背景…如果我设置ulimit -v 1024000,然后用ulimit -v检查它我得到正确的值’1024000′.如果我再次运行脚本,它将进一步发展,但最终会在达到相同的内存限制(~360MB)时出错.如果我立即检查ulimit -v,它已重置为原始值’524288′.这似乎可能是问题的根本原因. 我试过的 增加PHP的memory_limit 鉴于php.ini文件: php -i | grep php.ini Configuration File (php.ini) Path => /usr/local/lib Loaded Configuration File => /usr/local/lib/php.ini 我编辑了那个文件,所以memory_limit指令读取; memory_limit = -1 重启Apache,检查新值是否卡住了; $php -i | grep memory_limit memory_limit => -1 => -1 运行脚本,并得到相同的错误. 我也试过1G,768M等,都是为了相同的结果(即没有变化). 6月22日更新:基于Vangel’s help,我尝试将post_max_size设置为20M并结合设置memory_limit.同样,这没有任何效果. 6月23日更新:根据olefebvre’s help,我可以确认运行脚本的用户对包含memory_limit设置的php.ini文件具有读/写权限. 删除Apache子进程的内存限制 我找到并编辑了httpd.conf文件,以确保没有RLimitMEM指令. 然后我使用了WHM的Apache配置>内存使用限制生成限制,它声称是1000M(并通过检查httpd.conf确认). 这两个都导致360MB的脚本错误没有变化. 增加Linux的每进程内存限制 系统上设置的当前限制: $ulimit -m 524288 $ulimit -v 524288 我试图将这两个设置为无限制: $ulimit -m unlimited $ulimit -v unlimited $ulimit -m unlimited $ulimit -v unlimited 再一次,这导致了我的问题绝对没有改善. 6月23日更新:我在这里遇到了一个相关的问题.如果我设置ulimit -v 1024000,然后用ulimit -v检查它,我得到正确的值’1024000′.如果我再次运行脚本,但最终会在达到相同的内存限制时出错.如果我立即检查ulimit -v,它已重置为原始值’524288′.这似乎可能是问题的根本原因. 我的设置 $cat /etc/redhat-release CentOS release 5.5 (Final) $uname -a Linux example.com 2.6.18-164.15.1.el5 #1 SMP Wed Mar 17 11:30:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux $php -i | grep "PHP Version" PHP Version => 5.2.9 $httpd -V Server version: Apache/2.0.63 Server built: Feb 2 2011 01:25:12 Cpanel::Easy::Apache v3.2.0 rev5291 Server's Module Magic Number: 20020903:13 Server loaded: APR 0.9.17,APR-UTIL 0.9.15 Compiled using: APR 0.9.17,APR-UTIL 0.9.15 Architecture: 64-bit Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D HTTPD_ROOT="/usr/local/apache" -D SUEXEC_BIN="/usr/local/apache/bin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" 输出$php -i:http://pastebin.com/EiRut6Nm 解决方法
背景:
我刚刚抓住当前版本的Piwik – 在版本1.5中,第969行显示为: public function addRowsFromSerializedArray( $stringSerialized ) { $serialized = unserialize($stringSerialized); if($serialized === false) { throw new Exception("The unserialization has failed!"); } $this->addRowsFromArray($serialized); } 并且特别是$serialized = unserialize($stringSerialized);.对反序列化的调用可能是令人难以置信的内存密集型.有一个很好的职位here. 正如您所指出的,这显然不是您脚本中的错误,并且是有效的内存不足. 建议:在配置文件中,如上面评论中所述: /…/piwik/config/global.ini.php 我想你可能需要增加其中一个限制: # during archiving,Piwik will limit the number of results recorded,for performance reasons # maximum number of rows for any of the Referers tables (keywords,search engines,campaigns,etc.) # this limit will also be applied to the Custom Variables names and values reports datatable_archiving_maximum_rows_referers = 1000 # maximum number of rows for any of the Referers subtable (search engines by keyword,keyword by campaign,etc.) datatable_archiving_maximum_rows_subtable_referers = 50 # maximum number of rows for any of the Actions tables (pages,downloads,outlinks) datatable_archiving_maximum_rows_actions = 500 # maximum number of rows for pages in categories (sub pages,when clicking on the + for a page category) # note: should not exceed the display limit in Piwik_Actions_Controller::ACTIONS_REPORT_ROWS_DISPLAY # because each subdirectory doesn't have paging at the bottom,so all data should be displayed if possible. datatable_archiving_maximum_rows_subtable_actions = 100 # maximum number of rows for other tables (Providers,User settings configurations) datatable_archiving_maximum_rows_standard = 500 我将分号更改为#sign只是为了使sf的autocolor可读. 您也可以尝试添加: CMD_TO_CHECK_SETTINGS="$PHP_BIN -i > /tmp/piwik-php-env.out" $CMD_TO_CHECK_SETTINGS 到archive.sh以确定是否有其他设置正在覆盖php.ini文件. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- awk多种模式
- linux-kernel – 不带-o循环安装
- linux – 将nautilus打开文件放入新的gvim缓冲区吗?
- Linux上的传入(入口)流量整形 – bw低于预期
- root和子文件夹中的.htaccess,每个都重定向到自己的index.p
- linux – WebDriverError错误:Chrome无法启动:异常退出
- 有谁知道如何在linux中创建一个sybmbolic“目录”?
- linux – Tomcat在没有错误的情况下启动,但没有在8080上监听
- 在Linux服务上运行时,Java编码是否已损坏?
- search.h-在Android-tiff 4.0.1上移植libtiff时没有这样的文