You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that ASP net apps that consume MQTT messages also use a lot more memory than console apps that subscribe to the same data.
The memory never seems to be released. Running dotMemory shows that the app uses a lot of unmanaged memory
Which component is your bug related to?
Client, version 4.3.7.1207
Memory consumption of the Producer console app, Consumer console app and Consumer Asp Net 6 app:
usingMQTTnet;usingMQTTnet.Client;namespaceWebApplication1;publicclassMqttHostedService:IHostedService{privatereadonlyIMqttClient_client;privatereadonlyMqttClientOptions_options;publicMqttHostedService(){varfactory=newMqttFactory();_client=factory.CreateMqttClient();_options=newMqttClientOptionsBuilder().WithClientId("ListenerClientAsp6").WithTcpServer("localhost",1883).Build();_client.ApplicationMessageReceivedAsync+= e =>{returnTask.CompletedTask;};}publicasyncTaskStartAsync(CancellationTokencancellationToken){await_client.ConnectAsync(_options,cancellationToken);await_client.SubscribeAsync(newMqttTopicFilterBuilder().WithTopic("large/dto").Build());}publicasyncTaskStopAsync(CancellationTokencancellationToken){vardisconnectOptions=newMqttClientDisconnectOptions{Reason=MqttClientDisconnectOptionsReason.NormalDisconnection,ReasonString="Service stopping"};await_client.DisconnectAsync(disconnectOptions,cancellationToken);}}
The text was updated successfully, but these errors were encountered:
@xljiulang Thanks for your reply. When forcing the ASP net app to use workstation GC, i see very similar memory usage to the console app, like you said.
When using Server GC though, even when disconnecting to the MQTT server and disposing the client, the memory never seems to be released, even when i force a GC. Not sure if this is related to MQTTNet or if it's just how .Net works in this mode.
I've noticed that ASP net apps that consume MQTT messages also use a lot more memory than console apps that subscribe to the same data.
The memory never seems to be released. Running dotMemory shows that the app uses a lot of unmanaged memory
Which component is your bug related to?
Memory consumption of the Producer console app, Consumer console app and Consumer Asp Net 6 app:
Create a console app that pushes data to the bus:
Program.cs:
Create an ASP Net web API (tested both .Net 6 and .Net 8)
Program.cs:
MqttHostedService.cs
The text was updated successfully, but these errors were encountered: