繁体   English   中英

非常奇怪的错误代码

[英]Very strange error code

我有一个曾经工作过的脚本。 现在,我上传了它,它回复了:

[06-Jan-2014 13:23:52 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:23:53 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:23:54 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:25:08 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:25:29 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:26:05 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165
[06-Jan-2014 13:26:08 UTC] PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 130968 bytes) in /home/statsaff/public_html/customforthisdomain.php on line 165 

经过进一步调查,我发现:

  1. 无论我如何修改customforthisdomain.php该错误是完全相同的
  2. 实际上,我已经安排脚本中的第165行为空
  3. 该错误仅在Firefox上显示。 该脚本在Internet Explorer上运行良好。

这是第165行的代码,为空

function mainURL()
{
    $domain=getDomain();

    $dictionary=getDomainDictionary();
    return $dictionary[MAINURL];
}

//..

function getDomainDictionary()

第165行在该空白区域内。

令我发狂的是,据说该错误发生在第165行。但是,第165行没有发生任何事情。无论我如何更改脚本,该错误消息都会不断地指出该错误发生在第165行。

我将文件分成2个文件。 然后,我开始将代码从一个文件移动到另一个文件。

罪魁祸首似乎在这一行

function getDomain()
{
    $domain=$_SERVER['SERVER_NAME'];
    $domain = str_replace("www.", "", $domain);

    /*if ($_GET['asdomain'])
    {
        $domain=$_GET['asdomain'];
    }*/
    return $domain;
}

如果我取消注释注释行,则错误在customdomain1.php中。 如果我发表评论,该错误是在getcountryotherway.php中

罪魁祸首行始终为165。尽管该文件甚至不包含165行。

有两种方法可以弄乱这里。 首先是缓存配置错误。 在SilverStripe安装中,必须存在silverstripe-cache。 这个网站很相关。

www.meerware.com/thoughts/2013/07/choose-your-silverstripe-cache-location-carefully/

您的php可能具有不同的缓存,但是不可写的缓存会导致无限的内存消耗。

此外,如果selinux或权限问题阻止了高速缓存位置的可写性,则可能会有相同的问题。

该错误的可能原因:

  • 脚本占用过多内存
  • 错误/无限循环,例如while,foreach,for
  • 缓存文件也可能导致

如果您无法更改服务器的php配置,则必须分析代码并进行一些改进。

由于服务器的配置,浏览器应该不会出现问题。 也许清除缓存,然后重试?

更新PHP.ini或使用init_set更改限制。

 ini_set("memory_limit","12M");

12Mo是极限。

我解决了这个问题。 一些功能保持递归调用。 此后,我已修复该问题。 不知道为什么总是说错误在第165行。第165行什么也没有。这是严重的误导。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM