> Please write a concrete RFC, many people want arenas and pools but it's not 
> clear what exactly that implies.

First I’d like to get a feeling for if there’s anything already out there close 
enough for my use case.

My interest is more of a memory “cache” per thread that uses malloc to get 
larger memory blocks but then provides a cache of re-useable chunks of memory 
for the current thread without requiring locks/mutexes. Arenas would seem like 
a very fast way to provide such thread-local memory caching.

In particular on embedded devices using the system’s malloc is expensive. It’s 
not terrible but keeping code fast requires a fair bit of effort to avoid 
allocations. It’d be nice to be able to repeatedly create-and-free a bunch of 
small objects without the slowdown from lots of calls to malloc. Currently I 
have to manually pre-allocate objects and reuse them to speed up sections of 
code.

Unfortunately, neither the standaloneheap or the virtual pages allocators work 
well on many MCU’s.

@PMunch’s suggestion I believe relies on virtual memory. @Planeti’s link to the 
fusion lib pool allocator could work… but it’s unclear how this could be used 
with libraries. Still it could work well for many use cases.

It’s not currently possible to annotate a block of code or function to use a 
custom allocator, is it? That’s seems like it’d be difficult to implement! 
Possibly I’m thinking of the “region” based memory management that was 
experimented with at some point.

I could write an RFC if it’d be helpful. I’ve gone back and forth over it being 
worthwhile issue to pursue. 

Reply via email to