This thread is archived
2 Replies Last post: Dec 6, 2005 9:38 AM by Mario Scalas  
Mario Scalas   6 posts since
Nov 11, 2005
Currently Being Moderated

Dec 5, 2005 9:06 AM

Leave() a MultiUserChat will also clean-up the registered listeners?

The doc at http://www.jivesoftware.org/builds/smack/docs/latest/javadoc/org/jivesoftware/sm ackx/muc/MultiUserChat.html#leave()

doesn''t specify this: can I proceed confidend that doing something like:

 

void closeConference() {

    muc.leave();

    muc = null;

}

 

is enough() or have I to manually remove all the listeners I registered at creation time?

Alex Wenckus Jiver 1,029 posts since
Jan 13, 2005
Currently Being Moderated
Dec 5, 2005 10:34 AM in response to: Mario Scalas
Re: Leave() a MultiUserChat will also clean-up the registered listeners?

The best practice to get in the habit of is to generally remove all listeners you create. The MUC cleans up its resources at finalize time, so if either of the objects the MUC or the object you have listening to the MUC have strong references somewhere in your program this finalize method will not be called and both the objects will remain in memory indefintly.

 

Though, if you don''t have any strong references to the object you are listening on, you should be fine, I would still recomend that you manually remove the listeners to be assured of the objects garbage collection.

 

Alex

More Like This

  • Retrieving data ...