PHP/Apache 的内存上限 [英] Upper memory limit for PHP/Apache
问题描述
运行 PHP 脚本时出现错误....
I'm getting the error when I run my PHP script....
Fatal error: Out of memory (allocated 1827405824) (tried to allocate 88800 bytes)
我已将此行添加到我的 PHP 脚本中..
I've added this line to my PHP script..
ini_set("memory_limit","3000M");
此语句似乎确实正确控制了内存使用,但我似乎无法将其提高到大约 1.8GB 以上.就好像内存上限在其他地方受到限制.我还添加到 php.ini ...
This statement does seem to correctly control the memory usage, but I dont seem to be able to get it above about 1.8GB. Its as if the upper memory limit is being restricted somewhere else. I've also added to the php.ini...
memory_limit = 3000M
有谁知道其他地方的内存是否受限?
Does anyone know if the memory is restricted elsewhere?
我正在使用 Xampp 运行本地服务器.我有带有 4GB RAM 的 64 位 Windows 7.我的脚本使用 PHP 的 GD 图像库,尝试使用 ImageCreateTrueColor() 分配图像引用时出现错误.
I'm running a local server with Xampp. I have Windows 7, 64-bit with 4GB RAM. My script uses PHP's GD image library and I get the error when trying to allocate an image reference with ImageCreateTrueColor().
(我知道这是一个巨大的内存量 - 但这只是一个单一的脚本,而且以这种方式执行它要容易得多.)
(I know this is a huge amount of memory - but this is just a one-of script, and its just a lot easier to do it this way.)
谢谢.
更新....
@难以捉摸的@Orbling我希望每个人都对这个问题感到厌烦,但这里是说明问题的简化代码.
@elusive @Orbling I expect everybody's bored whith this question, but here is the simplified code which illustrates the problem.
<?php
ini_set("memory_limit","4000000000");
echo "ini_get = " . ini_get('memory_limit') . "<br>\n";
echo "memory_get_usage = " . memory_get_usage(true) . "<br>\n";
$bigImageHandle = imagecreatetruecolor(22200, 24800); //this is line 5
?>
浏览器输出...
ini_get = 4000000000
memory_get_usage = 524288
Fatal error: Out of memory (allocated 1843396608) (tried to allocate 88800 bytes) in
E:\User\My_Webs\experiments\houseshunting\temp\osMaps\t1.php on line 5
我用一组较小的图块和 imagecreatetruecolor() 使用的内存对此进行了测试,我估计我需要 2.7GB
I tested this out with a smaller set of tiles and the memory used by imagecreatetruecolor() and I estimate I need 2.7GB
推荐答案
使用 Acquia Dev Desktop,我遇到了很多内存限制崩溃.
Using Acquia Dev Desktop, I had many memory limit crashes.
在将内存限制增加到 PHP.ini 之后.
After having increased the memory limit into PHP.ini.
php_value memory_limit 1024M
php_value max_execution_time 3000
这个问题不那么频繁,但仍然发生(特别是使用特征重新创建)
This issue was less frequent but still occuring ( Especially with Feature Recreate )
在我的 httpd.conf 中,我将 StackThread 增加到 16M
Into my httpd.conf I increased the StackThread to 16M
ThreadStackSize 16*1024*1024
它解决了内存崩溃问题.希望能帮到你
And it solved the memory crash issue. Hope it can help
这篇关于PHP/Apache 的内存上限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!