PHP脚本执行超出内存限制,即使限制更高

I have a PHP script on a Linux server that I am executing via command line like so: php script.php (note that it's not being executed as part of a web request).

The memory_limit in the server's "php.ini" file is set to "512M", and I have verified this as follows:

# echo "<?php phpinfo(); ?>" | php | grep memory_limit
memory_limit => 512M => 512M

Now, the issue is that when I execute the script in question via php script.php, eventually I get the following error:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 600283 bytes) in ...

268435456 bytes ~= 268mb, which is definitely lower than 512mb

What could be happening here? Is it possible there is another system-level setting I am missing? Or are php processes intrinsically limited to ~ 268mb?

Most likely php.ini settings didn't take effect. Restart the server again, and run script with phpinfo() to make sure your changes are in place.

You could use php -i and grep the output to check that you've updated the correct php.ini,

php -i | grep php.ini