wuschelhase
wuschelhase

Reputation: 1114

PHP memory exhausted although memory limit not reached

I am currently debugging a php-script. I set the memory_limit to 64M and it confirms this:

ini_set("memory_limit","64M");
echo "starting script with ".ini_get("memory_limit")."Bytes of ram\n"; \\64

But nevertheless the script breaks using just 20M giving the standard memory exhausted error.

Fatal error: Allowed memory size of 20971520 byte exhausted

Is there a possibility I probably did not think of ? Maybe Apache is setting something for PHP ?

Upvotes: 4

Views: 2431

Answers (2)

sibimani
sibimani

Reputation: 95

Better try this for unlimited memory:

ini_set("memory_limit",-1)

Upvotes: 4

oezi
oezi

Reputation: 51817

maybe the safe_mode is enabled on your server - if so, a lot of settings can't be changed using ini_set(). please take a look at your php.ini and check that.

EDIT: what happens if you change the value for memory_limit in the php.ini directly and restart/reload your apache (or whatever)? does it work in that case?

EDIT2 to wuschelhases comment:

  • have you restarted the apache after changing the php.ini? are you really sure you changed the correct php.ini (there may be not only one)?
  • what OS are your running (is this a linux-server, windows-server or a simple xampp-installation on your windows-home-pc)?
  • what does phpinfo() say about the memory-limit?

Upvotes: 3

Related Questions