高端内存限制PHP /阿帕奇 [英] Upper memory limit for PHP/Apache

查看:110
本文介绍了高端内存限制PHP /阿帕奇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的错误,当我运行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本地服务器。
我有Windows 7中,64位有4GB内存。
我的脚本使用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.)

感谢。

更新....

@elusive @Orbling
我希望每个人都厌倦蒙山这个问题,但这里是简化code这说明了这个问题。

@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
?>

浏览器输出...

Browser output...

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

推荐答案

您是在64位操作系统上运行,但Apache和PHP很可能仍然是32位。如果您使用mod_php,并且apache的是这里的限制因素。

You're running on a 64-bit operating system, but Apache and PHP are likely still 32-bit. If you're using mod_php, apache would be the limiting factor here.

32位的过程只有约的RAM 2GiB除非你使用了/ 3GB开关和软件知道3GB的支持。

32-bit processes are limited about 2GiB of RAM unless you used the /3GB switch and the software is aware of 3GB support.

这仍然留下了约200 MIB似乎未使用,但其足够小,它可以由都在存储器加载各种库被使用

That still leaves up about 200 MiB that seems unused, but its small enough that it can be used by various libraries that all have to be loaded in memory

据我所知,库的使用将不会在提交的内存露面,但在接近极限2GiB计数仍(很像设备内存朝着4GiB限制在32位Windows。当安装2吉布图形计算卡带给你到可用的RAM 2GiB)之下。

As far as I know, the library usage won't show up in the committed memory, but still counts towards the 2GiB limit (much like device memory counts towards the 4GiB limit on 32-bit windows. Where installing 2 GiB graphics card brings you down to under 2GiB of usable RAM).

最有可能的解决方案?安装64位的PHP,然后将其派遣到(使用system()调用,也许)

Most likely solution? Install a 64-bit PHP, and then dispatch it to that (using a system() call, perhaps)

这篇关于高端内存限制PHP /阿帕奇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆