views:

154

answers:

3

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.

A: 

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
John Boker
I'm running this under fastcgi, via nginx. I've updated my post to give this (relevant) info. Thanks!
bigmattyh
+1  A: 

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.

R. Bemrose
+1  A: 

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.

bigmattyh