1tgr / rust-websocket-lite

A fast, low-overhead WebSocket client
MIT License
115 stars 17 forks source link

Test for no memory allocation under normal use #23

Open 1tgr opened 4 years ago

1tgr commented 4 years ago

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.

1tgr commented 4 years ago

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.

petr-tik commented 4 years ago

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?