Hi Rustaceans !
I am porting c code for a small device and there we are using memory buffer pools, i.e. We create a large buffer at the boot time and then use varied sizes of the chunks as and when needed. Also, once done we return the chunk back to the pool. The pool get destroyed at the poweroff event and remain active as long as the device is on
My question, is there a crate available for this purpose ?, we use id as a handle to identify the chunk within the pool.
First time here and first time trying to use the Rust, but experienced in c/c++.
Based on that experience like to say "Thanks for creating the Rust "
Looking forward for the response
thanks
Is this embedded, meaning no_std and possibly also no alloc? Most memory pool crates rely on alloc, meaning they use the std library memory allocator, but some don't. So we need to know which type to search for. If you don't know, then you're probably just using the std library and the alloc packages.
Thanks for the quick response,
The answer is yes, it is embedded, but we can use the std and can do one big alloc
Ok. Your request is a little unusual because you need variable sized chunks, so it may a little time to search.
One more question: will multiple threads be allocating? I assume so.
What I'm doing is just searching at https://lib.rs/ based on what I already know about Rust memory arenas and pools.
The first possibility I've found is talc.
rarena_allocator looks pretty good.
Both of the above are concurrent (thread safe).
Thanks again,
Looks like that's what i want, but let me confirm by putting some tests around it.
You're welcome, good luck with it.
Another one that might work is arena_alloc although it has less downloads than the others.
If you can wait a day or so you'll probably get recommendations from people who have (unlike me) actually used something like this for embedded work.
Ok, i would like to see other recommendations, just in case.
Thanks for taking time and answering this question.
Usually this is the job of the memory allocator. Do you know why the original C code doesn't use malloc/free for it? Maybe the default libc allocator being not good enough?
Hi @Hyeonu
Mainly because of the performance, we are trying to squeeze as much as possible.
thanks
I am planning to experiment with refpool refpool if the performance is acceptable, I will stick to it
thanks for all the help
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.