quic: avoid memory fragmentation issue
Original PR: https://github.com/nodejs/quic/pull/388 Previously, QuicPacket was allocating an std::vector<uint8_t> of NGTCP2_MAX_PKT_SIZE bytes, then the packet would be serialized into the buffer, and the std::vector would be resized based on the number of bytes serialized. I suspect the memory fragmentation that you're seeing is because of those resize operations not freeing memory in chunks that are aligned with the allocation. This changes QuicPacket to use a stack allocation that is always NGTCP2_MAX_PKT_SIZE bytes and the size of the serialized packet is just recorded without any resizing. When the memory is freed now, it should be freed in large enough chunks to cover subsequent allocations. Signed-off-by:James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/33912 Reviewed-By:
David Carlier <devnexen@gmail.com> Reviewed-By:
Matteo Collina <matteo.collina@gmail.com> Reviewed-By:
Denys Otrishko <shishugi@gmail.com>
parent
16116f5f
Please register or sign in to comment