dotnet / dotnet/MQTTnet

Unknown memory leak

Open
#1,836 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
5.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug
Memory usage runaway.

### Which component is your bug related to?
Server

### To Reproduce
Steps to reproduce the behavior:
1. Using version v4.3.0.858
2. Set up a simple server application with the following events
ValidatingConnectionAsync - Checks clients against database
InterceptingPublishAsync - Just to increase a counter to keep stats on number of msg handled
LoadingRetainedMessageAsync - Uses code from samples
RetainedMessageChangedAsync - Uses code from samples
3. The server has the following options:
```
var options = new MqttServerOptionsBuilder().
WithPersistentSessions(true).
WithConnectionBacklog(2000).
WithDefaultEndpointPort(1883).
WithDefaultEndpoint().
WithKeepAlive().
WithMaxPendingMessagesPerClient(20000);
```
4. See error.

### Expected behavior
The memory should vary with the number of connected clients and number of persistent messages in memory.

### Screenshots
![mqttNet leak](https://github.com/dotnet/MQTTnet/assets/31434537/977a0ee0-22fa-44c4-a6b8-c912667f8c9e)

### Additional context / logging
The server also has a timer, that once a sec updates the GUI with info about: connected clients, numb of processed msg and msg/sec.
Before I also displayed all connected clients in a ListView (WPF). Has worked without issue, but that was before everything was made asynchronous.

I made a client-app that spams the server with both connections and messages that should be persistent to try to
find the leak. I have not used the memory profiler before, but if I understand it correctly it has something to do with
getting the connected client count.

Let me know if I'm missing something.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.