我们一直在研究PHP程序,它耗尽了服务器内存。
内存似乎在if的假方面被用尽,但我们不知道为什么。以下示例显示了相关点的代码:
$memory = new MemoryUsageInformation(true);
$memory->setStart();
$a = 0;
for ($i=0; $i<8; $i++){
for ($y=1; $y<=50; $y++){
for ($m=1; $m<=12; $m++){
if ($a == 1){
echo 'Do I get here';
//30 + multidimensional arrays defined here.
}
$memory->setMemoryUsage('loop: '.$i.'.'.$y.'.'.$m);
}
}
}
$memory->setEnd();
$memory->printMemoryUsageInformation();
Time: 1412155564 | Memory Usage: 34.25 MB | Info: Initial Memory Usage
Time: 1412155564 | Memory Usage: 34.25 MB | Info: loop: 0.1.1
Time: 1412155564 | Memory Usage: 36.00 MB | Info: loop: 0.1.2
Time: 1412155564 | Memory Usage: 38.50 MB | Info: loop: 0.1.3
Time: 1412155564 | Memory Usage: 41.50 MB | Info: loop: 0.1.4
...
Time: 1412155564 | Memory Usage: 111.50 MB | Info: loop: 7.50.9
Time: 1412155564 | Memory Usage: 111.75 MB | Info: loop: 7.50.10
Time: 1412155564 | Memory Usage: 113.25 MB | Info: loop: 7.50.11
Time: 1412155564 | Memory Usage: 116.25 MB | Info: loop: 7.50.12
Time: 1412155564 | Memory Usage: 117.00 MB | Info: Memory Usage at the End
当我们注释掉在if语句中定义的数组时,内存不会耗尽并且程序会运行。
我们还尝试在if中回显文本以查看是否满足条件但是没有回显此文本。
我们对此感到有点难过,有人会有什么想法或建议来深入了解哪些内容?
感谢。