powered by Jive Software

Circular dependencies and memory leak

We(jitsi) recently upgraded to Smack 4.4.5 one of our components that was still using 4.2.
And we noticed some memory leaking of XMPP connections.
It happens because of the weak maps and the value (ServiceDisoveryManager) is holding a reference to the key (XMPPConnection).


Not sure what is the proper way to clean this… Is there a workaround for it, wdyt?

1 Like

Maybe just moving the final XMPPConnection connection = connection(); into the lambda will avoid storing the direct reference and will use the weak reference from org.jivesoftware.smack.Manager

WDYT?

I think you are right. The issue is not simply caused by obtaining a strong reference outside the lambda, but also due saving the action, which includes the lambda, in renewEntityCapsScheduledAction. And the lambda captures a strong reference to the connection, which in turn is strongly referenced by the action, which in turn we save in the renewEntityCapsScheduledAction field.

Created [SMACK-926] - Ignite Realtime Jira

Hey, @Flow do you plan a new 4.4 release soon that will include this?
Thank you

Well, I always consider multiple factors when to publish a new patch-level release. Users asking for it, is one factor. :slight_smile:

I assume this is such a request and I am happy to prepare the 4.4.6 release. But first, I’d like to confirm that the proposed fix solves the issue. Could you graph the next nightly build of 4.4.6-SNAPSHOT to test and confirm whether or not the issue is resolved?

I will test with the latest 4.4.6 snapshot once it is out and will report back.

It should be available here: Index of /repositories/snapshots/org/igniterealtime/smack, right?

If I try to run it locally I get the same errors as seen for the last few builds Smack - Nightly Binary Distribution Build (stable-branch): Plan summary - IgniteRealtime Bamboo
Is this also preventing the SNAPSHOTs to be uploaded?

No, ignore. I was on the wrong branch and I’m not able to build manually the 4.4 one because of the IqProvider thingy. I will wait for the SNAPSHOTs to be released.

I see it now, thanks for the trigger :slight_smile: testing now.

This commit [bosh] Use ConnectionConfiguration.getHostString() in BOSHConfiguration · igniterealtime/Smack@aa441d7 · GitHub breaks other stuff:
You dropped some ( which are needed.

Caused by: java.net.URISyntaxException: Expected authority at index 8: https://
	at java.base/java.net.URI$Parser.fail(URI.java:2915)
	at java.base/java.net.URI$Parser.failExpecting(URI.java:2921)
	at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3165)
	at java.base/java.net.URI$Parser.parse(URI.java:3116)
	at java.base/java.net.URI.<init>(URI.java:600)
	at org.jivesoftware.smack.bosh.BOSHConfiguration.getURI(BOSHConfiguration.java:81)
	at org.jivesoftware.smack.bosh.XMPPBOSHConnection.connectInternal(XMPPBOSHConnection.java:155)

It never hits getHostString()

Now that was a stupid mistake by me :confused: Sorry about that.

Just started the Bamboo CI Job to publish a new snapshot.

Thanks for the quick fix.
I confirm that the leak is fixed.
I tested with TCP and with Bosh XMPP connection that I reproduce it with 4.4.5 and I do not reproduce it with the latest snapshot 4.4.6-20220526.182902-3.

Thanks. I am going to publish 4.4.6 ASAP, but I can’t promise that I’ll find the time in the next 3-4 days.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.