yangdajun / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

memory leeck #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Roster.php
} else { //Nuke unavailable resources to save memory
    unset($this->roster_array[$jid]['resource'][$resource]);
}

change to

} else { //Nuke unavailable resources to save memory
    unset($this->roster_array[$jid]['presence'][$resource]);
}

Original issue reported on code.google.com by ivan.bor...@gmail.com on 2 Aug 2009 at 8:52

GoogleCodeExporter commented 8 years ago
I know another memory leak. This is feature of PHP garbage collector. It works 
very
bad with complex objects. To be really sure object will be destructed you must
destroy every internal variable. I'm use 

    public function destroy(){
        parent::destroy(); 
        foreach(get_object_vars($this) as $key => $value){
            unset($this->$key);
        }
    }

just after the disconnect.

To reproduce this kind of the memory leak, code is like:

while(true) {
    xmpp1 = new XMPPHP_XMPP(...);
    $xmpp1->connect();
    $xmpp1->processUntil(array('session_start'));
    $xmpp1->presence($status="Cheese!");
    //sleep(1);
    $xmpp1->disconnect();
    // $xmpp1->destroy(); // My destructor of XMPP object
}

Original comment by alexxz2...@gmail.com on 17 Aug 2009 at 5:03

GoogleCodeExporter commented 8 years ago
Fixed in http://github.com/cweiske/xmpphp

Original comment by cwei...@cweiske.de on 25 Feb 2010 at 6:53