Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Allow to Send Json Strings without duplicate Serialization #1546
Currently even if I have a JSON formatted string that I want to send to clients, SignalR server will still run it through the full serialization process, allocating additional memory. That could be avoided.
Motivation: in some scenarios, this can significantly lower memory consumption, since the message content would not duplicate for each sent message. i.e. currently when sending same message to 100 clients, the code would duplicate the content (json string) for reach client separately 100x. Referencing the same content, without serializing it again would greatly decrease the memory allocation per message.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
@halter73 We can do a few things here to allow this. The key method to look at is:
We can allow passing a raw ArraySegment (already serialized as JSON) and avoid this logic completely. That allows people to do their own serialization to json and give it to us as raw bytes.