rust-websocket-lite
rust-websocket-lite copied to clipboard
Test for no memory allocation under normal use
After initial buffers are allocated (or allocating a buffer on the stack), assert that no memory is allocated or freed to transmit or receive single-frame messages.
I added some asserts on the unit tests that check the expected behaviour of the message codec (that is, the raw parsing and message generation).
Memory tracking in a typical tokio-based send/receive loop still needs some thought. I would still expect no memory allocations beyond the initial buffer, which is owned by Tokyo's Framed struct.
https://crates.io/crates/alloc_counter
This crate looks like it might be useful. Although, it returns number of invocations of malloc, realloc and free, instead of number of bytes, syscall-granularity could be an acceptable substitue?