开发者

How else might a PHP CLI script determine its memory limit?

I need to run a PHP CLI script and give it a LOT of memory (it's an automatic documentation generator that needs to cover a large code base). I have a powerful machine and have allocated 5GB to php, both in php.ini and in an inline ini_set('memory_limit','5120M') declaration in the script file.

If I add these lines to top of the script:

phpinfo();
exit();

... it claims that it has a memory limit of 5120M, as I specified.

But the script still errors out, saying

Fatal error: Allowed memory size of 1073741824 bytes exhausted

... which is 1GB, not 5GB as I specified.

Is there any other place that the script might be looking to determine its memory limit? This is running in Fedora Linux.

(Yes, the ultimate solution may be to rewrite the script to be more efficient, but I didn't开发者_如何学运维 write it in the first place, so before I resort to that, I want to just throw resources at it and see if that works.)


The heap limit property is a size_t, which is 32 bits on a 32-bit machine. If this is in bytes, this would limit the memory limit to 4 GB. You may try running it on a 64 bit machine, with 64-bit PHP.

Edit: confirmed, heap->limit is a size_t (unsigned int) and is in bytes. A memory_limit of -1 sets the heap->limit to 4GB, and does not disable it as the documentation implies. Setting it to 5GB makes it wrap around to 1GB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜