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?
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.
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?
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.