PHP increase memory_limit above 128M
Changing of memory_limit
is blocked by suhosin extension.
From the docs at: http://www.hardened-php.net/suhosin/configuration.html#suhosin.memory_limit
suhosin.memory_limit
Type: Integer Default: 0 As long scripts are not running within safe_mode they are free to change the memory_limit to whatever value they want. Suhosin changes this fact and disallows setting the memory_limit to a value greater than the one the script started with, when this option is left at 0. A value greater than 0 means that Suhosin will disallows scripts setting the memory_limit to a value above this configured hard limit. This is for example usefull if you want to run the script normaly with a limit of 16M but image processing scripts may raise it to 20M.
So with suhosin extension enabled, you need to change it and restart apache.
user2554863
Updated on July 09, 2022Comments
-
user2554863 almost 2 years
I have running a Debian Squeeze with Standard Apache and PHP, installed via aptitude.
No I try to run :
<?php echo ini_get("memory_limit")."\n"; ini_set("memory_limit","1024M"); echo ini_get("memory_limit")."\n"; ?>
Result: 128M 128M
What I have tried to change this behavior and some facts:
/etc/php5/apache2/php.ini: safe_mode = Off memory_limit = 128M /etc/php5/apache2/conf.d/suhosin.ini: [suhosin] suhosin.memory_limit = 2048M
I can verify this settings with phpinfo();, after
service apache2 restart
.Why I can not set the Memory Limit above 128M?
Note:
<?php echo ini_get("memory_limit")."\n"; ini_set("memory_limit","127M"); echo ini_get("memory_limit")."\n"; ?>
Result: 128M 127M
Kind Regards
-
user2554863 over 10 yearsplease look on my first post :-)
-
vee over 10 years@user2554863, hmm just the patch! Have you tried disabling it and testing the memory limit or is that going to be a pain?
-
user2554863 over 10 yearsHi, I have comented out:
extension=suhosin.so
in /etc/php5/apache2/conf.d/suhosin.ini. After an Apache restart it works. Suhosin version is: Suhosin Patch 0.9.9.1. Do you have any help? I do not want to leave it off. -
vee over 10 yearsDon't really know how to help you except suggesting you to set higher memory limit and restart apache since you want to set higher memory limit. Why exactly do you want to set higher memory limit, may I know?
-
user2554863 over 10 yearsthat is for an internal Project. I want to give the possibility to download a rrd-database (oss.oetiker.ch/rrdtool). Therefore a time period can be given and I fetch the data within this period from the database with
rrd_fetch()
. Than I convert it to json and deliver it. -
vee over 10 yearsNot possible to improve the script at all? If so, very bad option I am giving you next, have you tried with max_execution_time(-1) or a sensible number to allow the script to complete it's task? only if this script runs at a time when the server has minimal load, probably during off hours.
-
user2554863 over 10 yearsI get an php memory error
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted ...
This is because the database is to big -
vee over 10 yearsWell...
rrd_fetch()
seems to havestart
andend
parameters, so the best thing to do would be download and process in smaller chunks. Have you not tried that? -
user2554863 over 10 yearsI know this and I will try. But the fastest (and dirtiest :-)) solution was increasing the memory size (I was thinking).
-
user2554863 over 10 yearsplease look on stackoverflow.com/questions/18146965/…