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
When I was doing performance optimization extension for MqttServer's InjectApplicationMessage , I used ArrayPool<byte> memory and unexpectedly found that the test QoS_Tests.Preserve_Message_Order_For_Queued_Messages failed because I cleared and recycled poolPayload after await MqttServer.InjectApplicationMessage( poolPayload) . I think there is no problem with my operation timing, and this behavior should be allowed.
If I use the byte[] poolPayload that I manually new, this test is successful. The reason is that the caller provides a payload in an independent space for InjectApplicationMessage, and this payload will only be used by MqttServer in the future until it is recycled by GC.
Which component is your bug related to?
Server
To Reproduce
Modify the InjectApplicationMessage code of MqttServerExtensions and run the test Preserve_Message_Order_For_Queued_Messages.
publicstaticasyncTaskInjectApplicationMessage(thisMqttServerserver,stringtopic,stringpayload=null,MqttQualityOfServiceLevelqualityOfServiceLevel=MqttQualityOfServiceLevel.AtMostOnce,boolretain=false){ArgumentNullException.ThrowIfNull(server);ArgumentNullException.ThrowIfNull(topic);varpayloadBuffer=Encoding.UTF8.GetBytes(payload??string.Empty);varmessage=newMqttApplicationMessageBuilder().WithTopic(topic).WithPayload(payloadBuffer).WithQualityOfServiceLevel(qualityOfServiceLevel).WithRetainFlag(retain).Build();awaitserver.InjectApplicationMessage(newInjectedMqttApplicationMessage(message));// clear the bufferpayloadBuffer.AsSpan().Clear();}
Expected behavior
After await InjectApplicationMessage(), the memory reference to the payload must be released.
The text was updated successfully, but these errors were encountered:
Describe the bug
When I was doing performance optimization extension for MqttServer's InjectApplicationMessage , I used
ArrayPool<byte>
memory and unexpectedly found that the test QoS_Tests.Preserve_Message_Order_For_Queued_Messages failed because I cleared and recycled poolPayload afterawait MqttServer.InjectApplicationMessage( poolPayload)
. I think there is no problem with my operation timing, and this behavior should be allowed.If I use the byte[] poolPayload that I manually new, this test is successful. The reason is that the caller provides a payload in an independent space for InjectApplicationMessage, and this payload will only be used by MqttServer in the future until it is recycled by GC.
Which component is your bug related to?
To Reproduce
Modify the InjectApplicationMessage code of MqttServerExtensions and run the test Preserve_Message_Order_For_Queued_Messages.
Expected behavior
After await InjectApplicationMessage(), the memory reference to the payload must be released.
The text was updated successfully, but these errors were encountered: