News for hackers. Stuff that matters.
Re:Goroutines, Nonblocking I/O, and Memory Usage by porpoisemonkey on Thursday January 05, 2017 @08:14PM (#13333104)
> 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.

Re:Goroutines, Nonblocking I/O, and Memory Usage by gpderetta on Friday January 06, 2017 @06:36AM (#13335543)
allocating 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.