tabris17
V2EX  ›  PHP

PHP Event 扩展有内存泄漏?

  •  
  •   tabris17 · Jan 20, 2015 · 3288 views
    This topic created in 4131 days ago, the information mentioned may be changed or developed.

    使用的是官网提供的代码,内存使用一路飙升

    <?php
    $base = new EventBase();
    $http = new EventHttp($base);

    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

    if (!$http->bind("127.0.0.1", 8080)) {
    exit("bind(1) failed\n");
    };

    $http->setDefaultCallback(function($req) {
    echo memory_get_usage(), PHP_EOL;
    $req->sendReply(200, "OK");
    });

    $base->dispatch();

    返回结果:
    3547968
    3548120
    3548272
    3548424
    3548576
    3548728
    3548880
    3549032
    3549184
    3549336
    3549488
    3549640
    3549792
    3549944
    3550096
    3550248
    3550400

    3 replies    2015-01-20 09:41:33 +08:00
    invite
        1
    invite  
       Jan 20, 2015
    PHP是立马回收的么?还是定期回收的?
    tabris17
        2
    tabris17  
    OP
       Jan 20, 2015
    即便使用gc_collect_cycles来强制启动gc也没用,应该是组件内部的有内存泄漏
    thankyourtender
        3
    thankyourtender  
       Jan 20, 2015
    PHP 很多bug都是插件引起的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 19:30 · PVG 03:30 · LAX 12:30 · JFK 15:30
    ♥ Do have faith in what you're doing.