PHP exec() use of memory

╄→гoц情女王★ 提交于 2020-01-11 05:43:38

问题


I can't seem to find a definitive answer for this one.

When invoking a shell command using exec() from PHP, does the memory that shell command uses count towards the memory limit that the PHP script is given?

I realise that if the command generates a lot of output, and that output is captured in the $ouput (second) parameter of exec(), then that returned data could blow the PHP memory limit. However, assuming all output is sent to a file, if the exec() command requires 128M of memory to run, should a PHP script with a limit of 64M of memory be able to run it?

<?php
exec('command_using_128M_memory >/dev/null 2>&1');

I'm assuming PHP5.3+


回答1:


The exec() command does not directly count towards the PHP since the process is executed separately not from within the PHP Process. Having said that if you use any output variable with the command they would count towards the limit.

So if you had a file which produced a lot of verbose logging, and you were capturing that logging it would count towards the memory limit.



来源:https://stackoverflow.com/questions/11291615/php-exec-use-of-memory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!