开发者

php background job cause exception on memory_limit

if i have a php background job, may need to run 4-5hours or more will it cause exce开发者_如何学Goption on memory_limit


PHP has a very primitive memory manager and scripts are not designed to run for very long. You can update the memory limit like this:

<?php ini_set(“memory_limit”,”256M”); ?>

But you will probably still have memory problems. You could try adding a ton of unset()'s to your script and this can help a bit. But the memory leaks are probably in PHP and its C/C++ extensions which you can't control. In the past I have had to rewrite background tasks in Java.


In your php.ini increase the amount for memory_limit.

See http://www.ducea.com/2008/02/14/increase-php-memory-limit/


Check out the following PHP commands:

// Sets the max time in seconds the script can run
set_time_limit($sec);
// Increases the memory limit (default is 1.5mb)
ini_set("memory_limit", "256M");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜