eclipse-paho / eclipse-paho/paho.mqtt.java

ConcurrentHashMap inboundQoS2 in org.eclipse.paho.mqttv5.client.internal.ClientState takes up over 100MB of HeapSpace

Open
#1,018 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

- [x] Bug exists Release Version 1.2.5 ( Master Branch)
- [ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)

Is this a normal behaviour that this single HashMap is using almost 50% of the applications total HeapSpace?

It doesn't seem to increase anymore although the message load is still the same.

![image](https://github.com/eclipse/paho.mqtt.java/assets/7070437/878bc667-649b-425b-9848-e31516b106ff)

I enabled logging and it seems that

https://github.com/eclipse/paho.mqtt.java/blob/570ed6eeaba81b0865821fed6de0d36142fedfde/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal/ClientState.java#L1532
or
https://github.com/eclipse/paho.mqtt.java/blob/570ed6eeaba81b0865821fed6de0d36142fedfde/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal/ClientState.java#L1542

are never called.

In the mosquitto log I see that the 4-Part Handshake was sucessfully

> 1695792469: Received PUBLISH from DEFAULT/s7tcp (d0, q2, r1, m632, 'DEFAULT/s7tcp/dev1/REAL1', ... (3 bytes))
> 1695792469: Sending PUBREC to DEFAULT/s7tcp (m632, rc0)
> 1695792469: Received PUBREL from DEFAULT/s7tcp (Mid: 632)
> 1695792469: Sending PUBLISH to DEFAULT/hmi (d0, q2, r0, m1199, 'DEFAULT/s7tcp/dev1/REAL1', ... (3 bytes))
> 1695792469: Sending PUBCOMP to DEFAULT/s7tcp (m632)
> 1695792469: Received PUBREC from DEFAULT/hmi (Mid: 1199)
> 1695792469: Sending PUBREL to DEFAULT/hmi (m1199)
> 1695792469: Received PUBCOMP from DEFAULT/hmi (Mid: 1199, RC:0)

Contributor guide

Open the contributing guide

Research direction

Start in org.eclipse.paho.mqttv5.client.internal.ClientState.java at the referenced lines around 1532 and 1542, then reproduce the heap growth while comparing the ClientState map with the broker's MQTT QoS 2 handshake log. Trace whether entries are removed after PUBCOMP and verify that sustained message load no longer leaves inboundQoS2 retaining over 100 MB.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.