3 ms·
> This method also has a benefit for performance: You often can totally avoid dynamic memory allocation during runtime with this model. You allocate the receive
by porpoisemonkey 10y ago
> This method also has a benefit for performance: You often can totally avoid dynamic memory allocation during runtime with this model. You allocate the receive buffer once for the connection and then reuse it for the whole lifetime.
There is a security concern here; you'd better be sure to flush the buffers correctly or you could cause memory to leak between sessions.
If I were writing a server to handle a sensitive task such as executing payment transactions I'd probably take the less memory efficient approach of allocating a new buffer for every connection to lower the risk of data spilling between connections.
- gpderetta 10y agoallocating a new buffer doesn't give any guarantee as you might be given back a just dealocated buffer by the allocator with its original content mostly intact. You need to explicitly scrub any sensitive data yourself before deallocating. At that point you might just reuse the buffer yourself.