1

正在发生的事情是,一个网页在 apache 日志中随机抛出“允许的内存耗尽”错误。我有两个时间的 xdebug 跟踪,问题发生的时间和正常运行的时间。当我比较跟踪文件时,令人惊讶的是看到日志条目没有任何函数名称和它们消耗的随机内存量。所以,有两件事我想了解。

  1. 我有以下代码

        if (function_exists('ini_set')) {
                ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
        }
    

如果发生错误,其跟踪日志为

2       23      0       0.007218        701448  function_exists 0      app/webroot/index.php  101    1       'ini_set'

2       23      1       0.007236        701448

2       24      0       0.007255        701592  ini_get 0              app/webroot/index.php  102    1       'include_path'

2       24      1       0.007277        701648

2       25      0       0.007288        701592  ini_set 0              app/webroot/index.php  102  

2       'include_path'  'httpdocs/lib:.:/usr/share/pear:/usr/share/php'

2       25      1       0.007617        702016

2       26      0       0.008726        755816  include 1       lib/Cake/bootstrap.php app/webroot/index.php  104    0

此日志有两个函数 ID 25 条目,即 ini_set(),内存为 701592 和 702016。第一个条目消耗的内存是 702016-701592 = 424 字节,第二个条目消耗的内存是 755816-702016 = 53800 字节。

我无法理解没有任何函数名称的第二个条目的存在,以及第二个条目的内存在哪里被使用?

  1. 第二个问题是,在我拥有的两个日志中,我可以注意到没有任何函数名称的日志条目所消耗的内存变化很大。

以下是另一次运行的日志。这里又是函数 ID 25 的两个条目,内存分别为 645616 和 646040。第一个条目消耗的内存是 646040-645616 = 424 字节(与前面相同),第二个条目消耗的内存是 646176-646040 = 136 字节(最后运行它是 53800 字节)。

同样,它在哪里被使用,为什么这个数量会有所不同!我可以在这两个跟踪日志中看到许多这样的偏差,总和到一定程度导致“允许的内存耗尽”错误。请帮助我理解这一点。

2       23      0       0.000908        645472  function_exists 0      app/webroot/index.php  101    1       'ini_set'

2       23      1       0.000924        645472

2       24      0       0.000936        645616  ini_get 0              app/webroot/index.php  102    1       'include_path'

2       24      1       0.000952        645672

2       25      0       0.000960        645616  ini_set 0              app/webroot/index.php  102    2       'include_path'  'lib:.:/usr/share/pear:/usr/share/php'

2       25      1       0.000996        646040

2       26      0       0.001034        646176  include 1       lib/Cake/bootstrap.php app/webroot/index.php  104    0
4

0 回答 0