duanbo5230 2011-08-30 17:57
浏览 47
已采纳

PHP 5.3中的PHP守护进程

While the idea of a PHP daemon has been covered to death on here, I haven't found anything specifically related to how to do this in PHP 5.3. As I've been told, 5.3 introduced new garbage collection/memory management to allow PHP to more cleanly run as a daemon.

I know PHP's no one's first choice for this kind of thing, but in my circumstances it might have to do.

I know in PHP 4, you would have to use something like the System_Daemon class, but I was wondering if that was still needed with the new version of PHP, and wether I'd need to do anything special to use the new features.

  • 写回答

2条回答 默认 最新

  • douguiyan9164 2011-08-30 18:06
    关注

    PHP uses reference counting for managing allocated memory. When a cycle exists between objects, their reference count is never decremented and the objects are never freed (until the end of the script).

    The only goal of the garbage collector added in PHP5.3 is to kill those cycles. This effectively helps in reducing the memory usage of long running scripts, like daemons.

    Other than that, PHP5.3 adds nothing new for long running scripts / daemons.

    There has been some efforts in making app servers in PHP lately, you may want to look at them:

    https://github.com/indeyets/appserver-in-php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样