Docs say nothing about pinning: If you allocate and then drop the allocator without calling deallocate, can the allocator free the underlying memory?
Amanieu: The answer is yes
So you can't allocate pinned objects, unless the allocator is 'static
. If it's 'static
we require (somewhere) that the memory must retain its validity.
Taylor: No, docs say that you can drop the allocation when the allocator is dropped…
Amanieu: the allocator itself must be static, but the lifetime to the allocator does not have to be
Memory blocks that are currently allocated by an allocator, must point to valid memory, and retain their validity while until either:
- the memory block is deallocated, or
- the allocator is dropped.
Amanieu: it's a bug that Box::leak
does not leak the allocator. That's unsound.
Taylor: Box::into_pin
, what happens if you leak that?
the8472: this is ok because the destructor is never called, and so the allocator never deallocates.
Taylor: I'd like stack-based allocators to be able to hold pinned objects.
the8472: RFC to allow overlapping marker trait implementations is already implemented? Would allow a marker trait rather than the static bound.
Allocator::grow is very poorly specified
What is the API benefit of having separate grow/shrink methods?
async hardware allocations???
Grow improvements:
https://github.com/rust-lang/wg-allocators/issues/112
Vec<T>
's allocation and reusing it for a Vec<U>
Global
Better let the caller handle it. Make it UB so allocator doesn't need to.
NonZeroLayout
would be nicetg: this issue is worth a read, it has some more concrete proposals that seem to approximately mirror the consensus in the meeting https://github.com/rust-lang/rust/issues/32838#issuecomment-2760323045