rust-websocket-lite icon indicating copy to clipboard operation
rust-websocket-lite copied to clipboard

Test for no memory allocation under normal use

Open 1tgr opened this issue 5 years ago • 2 comments

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 avatar Dec 02 '19 19:12 1tgr

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.

1tgr avatar Feb 23 '20 18:02 1tgr

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?

petr-tik avatar Apr 19 '20 18:04 petr-tik