BlockingClient receive(long, Duration) Memory leak
imascha opened this issue ยท 1 comments
imascha commented
๐ Bug Report
The member Variable List: entries
inside: com.hivemq.client.internal.mqtt.MqttBlockingClient.MqttPublishes
increases in size with each call to receive(long, Duration)
The entries
list seems to only get cleared, when a message to a subscribed topic is received. This can cause memory problems, when no message is received for a long time.
๐ฌ How To Reproduce
Steps to reproduce the behavior:
- Subscribe to a Topic that does not receive any messages
- Call
receive(long, Duration)
in a loop with a small duration. (Im using a larger duration in my application, but choose a small one here to reproduce the problem quicker)
Code sample
var blockingClient = Mqtt5Client.builder()
.identifier("blocking-subscriber")
.serverHost("localhost")
.serverPort(1883)
.automaticReconnectWithDefaultConfig()
.buildBlocking();
try (final Mqtt5BlockingClient.Mqtt5Publishes publishes = blockingClient.publishes(MqttGlobalPublishFilter.ALL)) {
blockingClient.connect();
blockingClient.subscribeWith().topicFilter("example/topic").send();
while (true) {
var publish = publishes.receive(1, TimeUnit.MICROSECONDS);
}
}
Environment
What version of this client are you using?
1.3.3
JVM version?
21
Operating System?
Windows 10
Which MQTT protocol version is being used?
5
Which MQTT broker (name and version)?
mosquitto 2.0.15
Screenshots
๐ Expected behavior
The entries
list should probably be periodically cleared, even when no messages are received.