set("memory

I had this working before :

echo ini_get("memory_limit")."n";
ini_set("memory_limit","256M");
echo ini_get("memory_limit")."n";

That would input this :

32M
256M

on a php script executed by command line. I updated from 5.2 to 5.3, and from now, this directive is not working at all : this gives me :

32M
32M

and then make my script fail with a fatal Error...

I checked the php documentation, and googled it, and I didn't find anywhere that "memory_limit" had been deprecated.

Does anyone have a solution?


Most likely your sushosin updated, which changed the default of suhosin.memory_limit from disabled to 0 (which won't allow any updates to memory_limit).

On Debian, change /etc/php5/conf.d/suhosin.ini

;suhosin.memory_limit = 0

to

suhosin.memory_limit = 2G

Or whichever value you are comfortable with. You can find the changelog of Sushosin at http://www.hardened-php.net/hphp/changelog.html, which says:

Changed the way the memory_limit protection is implemented


If you have the suhosin extension enabled, it can prevent scripts from setting the memory limit beyond what it started with or some defined cap.

http://www.hardened-php.net/suhosin/configuration.html#suhosin.memory_limit


Here's a list of things that are worth checking:

Is Suhosin installed?

  • How to check whether Suhosin is installed?
  • ini_set

  • The format is important ini_set('memory_limit', '512'); // DIDN'T WORK ini_set('memory_limit', '512MB'); // DIDN'T WORK ini_set('memory_limit', '512M'); // OK - 512MB ini_set('memory_limit', 512000000); // OK - 512MB ini_set('memory_limit', '512'); // DIDN'T WORK ini_set('memory_limit', '512MB'); // DIDN'T WORK ini_set('memory_limit', '512M'); // OK - 512MB ini_set('memory_limit', 512000000); // OK - 512MB
  • When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.

    http://php.net/manual/en/ini.core.php#ini.memory-limit

  • Has php_admin_value been used in .htaccess or virtualhost files?
  • Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value can not be overridden by .htaccess or ini_set(). To clear a previously set value use none as the value.

    http://php.net/manual/en/configuration.changes.php

    链接地址: http://www.djcxy.com/p/65076.html

    上一篇: 正则表达式不编译

    下一篇: 设置(“记忆