I have an problem increasing memory limit for PHP as Apache module.
If I put following directive in Apache configuration, that work OK:
php_value memory_limit 1.99G
But over 2GB do not work, it's restore this value back to 128MB.
What is the problem here? I need more memory for some PDF related tasks.
Server is Debian 2.6.32-5-amd64 #1 SMP, PHP 5.3.3-7+squeeze13 with 12GB physical RAM.
Have you tried using the value in MB ?
php_value memory_limit 2048M
Also try editing this value in php.ini
not Apache.
I would suggest you are looking at the problem in the wrong light. The questtion should be 'what am i doing that needs 2G memory inside a apache process with Php via apache module and is this tool set best suited for the job?'
Yes you can strap a rocket onto a ford pinto, but it's probably not the right solution.
Regardless, I'll provide the rocket if you really need it... you can add to the top of the script.
ini_set('memory_limit','2048M');
This will set it for just the script. You will still need to tell apache to allow that much for a php script (I think).
For unlimited memory limit set -1
in memory_limit
variable:
ini_set('memory_limit', '-1');
You should have 64-bit OS on hardware that supports 64-bit OS, 64-bit Apache version and the same for PHP. But this does not guarantee that functions that are work with PDF can use such big sizes of memory. You'd better not load the whole file into memory, split it into chunks or use file functions to seek on it without loading to RAM.
For others who are experiencing with the same problem, here is the description of the bug in php + patch https://bugs.php.net/bug.php?id=44522
Input the following to your Apache configuration:
php_value memory_limit 2048M
You can also try this:
ini_set("max_execution_time", "-1");
ini_set("memory_limit", "-1");
ignore_user_abort(true);
set_time_limit(0);
来源:https://stackoverflow.com/questions/11885191/how-to-increase-memory-limit-for-php-over-2gb