MemoryLeak due to implicit packet collectors

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

This is a known issue throughout Smack and has been fixed in some instances already in SVN. All instances of these leaks will be stomped out for the next major Smack release which will occur sometime after this upcoming Wildfire release.

Thanks,

Alex

Is there any workaround till the next release of smack is available?

Clear out the packet collectors using next message on the chat object or refrain from using the chat object all together.

Thanks,

Alex

meaning I’'d have to build the Packet myself and then use

org.jivesoftware.smack.XMPPConnection.sendPacket(Packet packet)

to send it?

thanks.

Exp,

That is correct.

Thanks,

Alex