linux – 无法删除PHP脚本的内存使用限制

linux – 无法删除PHP脚本的内存使用限制,第1张

概述情况 我遇到PHP脚本的问题,收到以下错误消息: 致命错误:969行/path/to/piwik/core/DataTable.php内存不足(分配359923712)(试图分配72个字节) 我正在运行的脚本是:/path/to/piwik/misc/cron/archive.sh 我假设数字是字节,这意味着总数约为360MB. 出于所有意图和目的,我已经将服务器上的内存限制增加到360MB以上, 情况

我遇到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.iniConfiguration file (PHP.ini) Path => /usr/local/libLoaded Configuration file => /usr/local/lib/PHP.ini

我编辑了那个文件,所以memory_limit指令读取;

memory_limit = -1

重启Apache,检查新值是否卡住了;

$PHP -i | grep memory_limitmemory_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 -m524288$ulimit -v524288

我试图将这两个设置为无限制:

$ulimit -m unlimited$ulimit -v unlimited$ulimit -munlimited$ulimit -vunlimited

再一次,这导致了我的问题绝对没有改善.

6月23日更新:我在这里遇到了一个相关的问题.如果我设置ulimit -v 1024000,然后用ulimit -v检查它,我得到正确的值’1024000′.如果我再次运行脚本,但最终会在达到相同的内存限制时出错.如果我立即检查ulimit -v,它已重置为原始值’524288′.这似乎可能是问题的根本原因.

我的设置

$cat /etc/redhat-releaseCentOS release 5.5 (Final)$uname -alinux 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 -VServer version: Apache/2.0.63Server built:   Feb  2 2011 01:25:12Cpanel::Easy::Apache v3.2.0 rev5291Server's Module Magic Number: 20020903:13Server loaded:  APR 0.9.17,APR-UTIL 0.9.15Compiled using: APR 0.9.17,APR-UTIL 0.9.15Architecture:   64-bitServer 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 reportsdatatable_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文件.

总结

以上是内存溢出为你收集整理的linux – 无法删除PHP脚本的内存使用限制全部内容,希望文章能够帮你解决linux – 无法删除PHP脚本的内存使用限制所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1039523.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存