Is it the same leak?

Hi there. I have been using smack in an experimental application, problem is the memory runs out really quick.

Reading a post on this forum, i decided to modify the source code ad add a .cancel() function to the CHAT object. It turns out in fact that it contains a packetCollector which does in fact need to be explicitally removed for it to stop logging (GC will not fix that).

After adding the .cancel() to che chat object the memory loss improoved. that is is not loosing as before but it isnt fixed yet in a continuous loop i loose 1-2m a minute. I invoke regularly the vm .gc but it doesnt work… therefore its not a vm problem.

Analying the memory with eclise i see there are a number of packet collectors instanciated … :-/ how to procede?

When is the announced fix coming out ?

Thanks for all anyway

Sincerely

Moving this to the smack forum.

Can you post your code snippet that demonstrates a memory leak? You do need to be careful to cancel all packet collectors. We’‘re talking about adding weak references to packet collectors and listeners so that they can be automatically gc’‘ed, but that change won’'t be coming for a bit still.

Regards,

Matt

Ok, worked more than an hour (its a complex project) and managed to extract this. It’'s a standalone project. First launch “server” then lauch “client”.

It will use my jabber server here in italy, but that’'s ok. Watch the memory of “server” as it grows to infinity real quick (say 2 megs per minute?) i here run it locally it might take a bit longer on your side

A look at it with a memory profiler confirmed its a bunch of packets and xml stuck somewhere inside in the smack objects

the server code its actually as easy as it gets, i hardly think it can be a bug in the way i coded this.

Thanks for your assistence. If we can fix this it solves me a hard problem and i’'ll be happy, got a paypal for donations? sincerely
smackattack.zip (65535 Bytes)

I here add that its not a matter of the CHAT object implementation! we rewrote the thing not to use chat but just simple Messages but its behaving exactly the same way. What’'s next?

I’'m going to try to get to the bottom of this issue today and will let you know what I find. BTW, are you testing with 1.3.0 or a recent daily build?

Thanks,

Matt

we onle tested it with the official release, a quick run with the daily build gives this stacktrace:

org.xmlpull.v1.XmlPullParserException: parser must be on START_TAG to read next text (position: TEXT seen …entrypointuri</… @1:802)

at org.xmlpull.mxp1.MXParser.nextText(MXParser.java:1099)

at org.jivesoftware.smack.PacketReader.parseProperties(PacketReader.java:754)

at org.jivesoftware.smack.PacketReader.parseMessage(PacketReader.java:643)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:274)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:77)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:103)

thanks for your quick reply…

Bye

Giovanni,

Could you post the XML stanza that you are receiving that is generating this error? You can use the debugger window to get the XML.

Thanks,

– Gato

I will try to post it… however its easy to try , just use the code i posted above with the new Jar.

Matt how is it going with the memory? we started coding somethin ourself yesterday but we’'d really rather use your lib.

Sincerely

Viciously posting again so that this issue doesnt get forgotten

Guys, out of desperation i have coded something similar to jabber myself, … when i finished (2 days of work) i had… the same memory problem!!!

totally amazed i looked hard into my code to find the problem being that i didnt call the “reset()” method on the ObjectOutputStream object some idiot at Sun though it might be interesting to have the ObjectOutput Stream cache ALL the objects that are being sent around and that caused memory problems very similar with the ones i am experiencing with smack, it basically grew forever. Maybe you have to call some similar method in your streams? Just a hint. Still looking forward for a fix about this though, i’'d hate to have to trow away all my jabber code.

Hmm, this could indeed be an issue. From looking at the code, I’‘m not super careful about closing the ObjectOutputStream when writing Object properties. I’‘m fixing the code now, so I’‘d recommend trying tomorrow’'s daily build to see if it solves the issue.

-Matt

Actually, I erased today’'s daily build and made a new one that includes the fix (July 12). Please let me know if it works for you!

Regards,

Matt

MATT i get this

Got connection closed on error

org.xmlpull.v1.XmlPullParserException: parser must be on START_TAG to read next text (position: TEXT seen …entrypointuri</… @1:802)

at org.xmlpull.mxp1.MXParser.nextText(MXParser.java:1099)

at org.jivesoftware.smack.PacketReader.parseProperties(PacketReader.java:754)

at org.jivesoftware.smack.PacketReader.parseMessage(PacketReader.java:643)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:274)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:77)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:103)

.

when running the above posted stuff could you fix it please? you have it all … just run “server” and then run “client” its supposed to work but blows.

Giovanni,

Thanks for the bug report. We already created a fix for this problem which should be available in the next daily build.

Thanks,

– Gato