Hi,
I am using smack for a small Jabber client application. It works fine for a day or two but then I run into problems because the smack library has taken up all the available HEAP memory.
I’'ve analyzed a heap dump with JHat and I see the following indications for leaks:
instances classname
259602 org.jivesoftware.smack.packet.RosterPacket$Item
1471 org.jivesoftware.smack.packet.Presence
1102 org.jivesoftware.smack.packet.RosterPacket
1933 org.jivesoftware.smack.packet.DefaultPacketExtension
code to receive messages:
PacketCollector collector = connection.createPacketCollector( null );
while ( true ) {
… = collector.nextResult();
…
}
(note: this is runnin non-stop in a background thread)
code to send messages:
public void sendMessage ( String jabberAddress, String message ) {
Chat chat = con.createChat( jabberAddress );
chat.sendMessage( message );
}
(note: the chat object is going out of scope here after each message send and seems to be correctly garbage collected, there were no allocated chat objects in the heap dump)
the roster is also used:
roster = connection.getRoster();
roster.setSubscriptionMode( Roster.SUBSCRIPTION_ACCEPT_ALL );
…
roster.reload();
…
List class org.jivesoftware.smack.packet.Presence (84 bytes)
Thanks
H. Meyer