English 中文(简体)
What s limiting my PHP resources?
原标题:

I m having a problem getting more memory out of PHP.

This is the error message:

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 82 bytes) in ...

Yet:

I ve set memory_limit in the php.ini file to 32M:

memory_limit = 32M;

I ve also tried to override it manually in the actual script:

ini_set( memory_limit ,  32M );

And -- here s where I m lost -- I ve confirmed via phpinfo() that this php.ini file is the actual ini file used, and the memory_limit seems to be set correctly. The line on memory_limit gives this:

memory_limit    32M 32M

So it would seem that everything is configured properly, but I m only getting 20971520 bytes (~20M).

Where else should I be looking to figure out where this limitation is being imposed?

EDIT: I m running php under nginx/fastcgi, on Ubuntu 9.04 in a VPS. The php-cgi processes do seem to be a bit resource-hungry (RES=25m, VIRT=187m), but I have 10m of physical memory free and 500m of swap space free.

最佳回答

I just pored over the code I was running, and someone had hard-coded this into a config file:

ini_set( memory_limit ,  20M );

Which was overriding everything else I was doing. Whew.

问题回答

My first instinct is to guess that PHP is reading a different php.ini.

In Debian (and most likely Ubuntu), each version of PHP (cli, cgi, and apache) has its own copy of php.ini.

You could try setting it in the .htaccess file, that is what i had to do to get a site working on one server.

here are the settings i used:

php_value  upload_max_filesize  50M
php_value  post_max_size  60M
php_value  memory_limit  128M




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签