6

for some reason, my one of my php scripts are ignoring the php.ini memory limit or ini_set.

When i do a print_r(ini_get_all) it shows the global memory limit set to 100M (and local for that matter), when my script dies at Fatal error: Out of memory (allocated 24714304) (tried to allocate 571 bytes)

Any tips on diagnosing this? The server has 8gigs of memory and never had problems running this script before.

Any tips on debugging this?

Thanks!

3 Answers 3

5

The single most common cause of this is that usually the CLI PHP binary is using a different php.ini file than you expect. This can be caused by user permissions, or simply different default php.ini files for installed versions of PHP. However, it sounds like you've profiled it a bit and your memory limit may be correct inside your script.

In that case, it's quite possible that there is a hard memory limit on processes that is imposed by your operating system, in which case you'll have to figure out where the imposition comes from.

I suggest taking a look at this thread, as that poster went through something very similar to your situation.

Sign up to request clarification or add additional context in comments.

3 Comments

you might be right, there may be a hard limit in effect. i have no clue how to find that. maybe i will ask on server fault!
you are a smart person i did some research about bash memory limits check out ulimit -v, which had hard limited my memory!!!
For me, the issue was running php-fpm but copying the config file into cli/conf.d instead of fpm/conf.d. Explains why php -i was showing my updated config but the script was still crashing.
5

The virtual memory for my processes was being hard limited (too a much lower number).

From a bash shell i did this:

ulimit -v (memory_in_bytes, no parentheses)

this fixed my problem. god i love stackoverflow

Comments

0

the short and sweet

ini_set('memory_limit', -1);

in case you want to skip the debugging

2 Comments

I think he is past that point already. His INI settings already are on 100M.
well i have done that but it did not work. In fact if i print out my phpinfo() it will show a much higher memory limit, and when i print out ini_get_all() any memory limit changes are shown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.