Recently I ran into memory allocation problems, so I started experimenting with the ini_set('memory_limit', value); directive ini_set('memory_limit', value); where I tried to enter values incrementally. Now, browsing the Internet (and SO), I found out that I can put -1 as value . So, I did, and now the script runs completely to the end without breaking (before I used the memory allocation error).
I do not understand, however, that these two lines are at the end of the script file:
$mem = memory_get_peak_usage(true); echo "Peak mem. usage: <b>" . round($mem / 1024 / 10124, 2) . "</b> MB";
produce around 10.8 MB , and when I look in /var/log/messages , I see this line:
Nov 21 13:52:26 mail suhosin[1153]: ALERT-SIMULATION - script tried to increase memory_limit to 4294967295 bytes which is above the allowed value (attacker 'xx.xxx.xxx.xxx', file '/var/www/html/file.php', line 5)
which means the script tried to allocate 4096 MB !
How can it be? And also, what interests me the most, why in this case the script stop stopped? This is due to ini_set('memory_limit', '-1'); ? I mean, I read that the placement is -1 , since value not recommended, and I know where the problem is in the script (reading too much data immediately in memory), and I will go and fix it with sequential reading, but I just puzzled by these differences in data, so I would appreciate it if someone could shed some light on him.