0

I was looking at Rust's Allocator trait. From my understanding, you give an allocator a length of memory and a word size to align to, and the allocator either gives you a pointer to the memory or an error. So clearly the custom Allocator is finding valid addresses in the memory somehow. How does the allocator know where in the heap it can allocate? Is there some "genesis" allocator that tells the custom Allocator which addresses it can take?

1 Answer 1

2

Custom allocators generally fall back to existing global allocators like libc malloc, and ultimately OS system calls like mmap on Linux to obtain allocatable memory. The point of custom allocators is to allow custom allocation strategies that might be more performant than the default ones for a specific use case.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.