Closed
Description
Follow up from "Resuable WebSocketReceiveResult" dotnet/corefx#4520
At the moment is WebSocketReceiveResult
is a read only POCO type that as a class must be garbage collected on every single socket message; probably gen0; but still bad for high speed websockets.
I can see two approaches to address this:
- Change the setters to protected, which opens up a possibility for types derived from
System.Net.WebSockets.WebSocket
to reuse the result object using a derivedWebSocketReceiveResult
type. - Change type from
class
tostruct
.
Either approach halves the number of allocations, second is safer but allocates more memory. (Though ValueTask returns could change this)