Rust Audio

Announcement: VecStorage: re-use the memory for vectors containing values with different lifetimes

:tada: I’m proud to announce vecstorage 0.1.0, a crate that helps you to avoid memory allocation in the real-time thread.

Quoting from the README:

In some situations, e.g. when writing real-time audio software, memory needs to be pre-allocated. The Vec data structure from Rust’s standard library can be used for this purpose. In some situations, however, you want to re-use the same Vec for data that has different lifetimes and Rust’s type system doesn’t allow this. This crate intends to help you overcome this problem.

3 Likes

That looks great! Just a question: Are you actually preventing memory allocations, for example by panicking if tried, or are you simply moving away the need to do so?

EDIT: I looked a bit more at the code and noticed that you even account for allocation changes when the guard is dropped. This already answers my question: It’s just about the reuse of allocated memory, not the prevention of allocations in general. Which is nice too! :+1: