I writing a jabber-bot that monitors MUC-participants. When participant joined to chat his presence added to presenceMap in Roster.java, but never be removed from there. As a result I have a growing XMPPConnection of jabber-bot. The only place where the call presenceMap.remove is RosterPacketListener.processPacket(Packet packet) (not called when participant left chat). Please help to resolve this problem.
This seems to be a quick and dirty fix, especially that the comment mentions the reason why we don’t remove the presence information from the presence map.
On the other hand, long running instances (like bots) could end up with an ever growing presence map. One solution could be an janitorial thread that cleans up old references from the map once every X hours or when it reaches a particular size.
We seems to be hitting the same problem in jicofo, our conference focus component, which is only using muc. I checked that this hasn’t been fixed even in new smack versions (we are still using an old one smack 3.2…). The simplest solution is to remove references for presence unavailable for which there is no RosterEntry.
Possible solution: When presence unavailable is received, remove any reference of the st… · jitsi/smack_3_2_2@ecbb546 · GitHub
Thanks Damian for the follow up. I’ve created SMACK-703 to track this.
After thinking again about it, I don’t even believe we would need such a janitorial thread as I mentioned above. Instead I think I would prefer the solution of using a bounded LRU cache like datastructure which holds the presences from entities not in the Roster, e.g. from a MUC. Compared to your solution of unconditionally not storing those presences.