3 ms·
Yeah, I hear you. I've not done a lot of FFI stuff directly, it scares me. Arena allocators are cool, the idea is you allocate a large-ish region of memory and
by samwho 3y ago
Yeah, I hear you. I've not done a lot of FFI stuff directly, it scares me.
Arena allocators are cool, the idea is you allocate a large-ish region of memory and sub-allocate into it (often with a fast, simple allocator like a bump allocator) and then free the large-ish block when you're done. It's a way to take knowing how much memory you need as a whole and optimise that to a single call to malloc/free.
You may enjoy looking through https://www.cs.usfca.edu/~galles/visualization/Algorithms.html https://www.cs.usfca.edu/~galles/visualization/Algorithms.ht....
- samsquire 3y agoThanks for the link to the animations. I want an extremely performant deep copy solution, I've been thinking of using an allocator to implement it. If we have a tree data structure or a nested hashmap, then we want to copy it cheaply, there is copy on write. But most copies of hashmaps are slow because they instantiate every child object in a recursive loop. So I want to be able to memcpy a complicated data structure for cheap copies.