It seems that CSteamNetworkingMessage doesn't pool messages.
This means that for each call to ISteamNetworkingUtils::AllocateMessage(), it dynamically allocates 264 bytes structure (on 64-bit environments).
This could be slow if you need to send loads of messages frequently.
I tried providing my own version of AllocateMessage() that allocates a message from my own pool, and initialize the CSteamNetworkingMessage properly.
But I realized you can't do that, because there's no way to initialize CSteamNetworkingMessage's private fields: m_links & m_linksSecondaryQueue
(Well, technically, I can just memset(msg, 0, 264) to initialize the hidden fields...
But not only that's UB, I can't tell if Steamworks SDK version of the message uses the same CSteamNetworkingMessage under the hood.)
It would be nice if there's an way to pool the message structure itself with the exposed m_pfnRelease,
like you can with m_pfnFreeData for the payloads.
Also, it would be great if you can also pool the message structure for the received messages too.
It seems that
CSteamNetworkingMessagedoesn't pool messages.This means that for each call to
ISteamNetworkingUtils::AllocateMessage(), it dynamically allocates 264 bytes structure (on 64-bit environments).This could be slow if you need to send loads of messages frequently.
I tried providing my own version of
AllocateMessage()that allocates a message from my own pool, and initialize theCSteamNetworkingMessageproperly.But I realized you can't do that, because there's no way to initialize
CSteamNetworkingMessage's private fields:m_links&m_linksSecondaryQueue(Well, technically, I can just
memset(msg, 0, 264)to initialize the hidden fields...But not only that's UB, I can't tell if Steamworks SDK version of the message uses the same
CSteamNetworkingMessageunder the hood.)It would be nice if there's an way to pool the message structure itself with the exposed
m_pfnRelease,like you can with
m_pfnFreeDatafor the payloads.Also, it would be great if you can also pool the message structure for the received messages too.