On 21/05/14 09:19 AM, Zoltán Tóth wrote:
> Daniel Micay <danielmi...@gmail.com <mailto:danielmi...@gmail.com>> wrote:
> 
>     ... the default
>     allocator, which is jemalloc right now.
> 
> 
> Rust's memory management is still under-documented in the manual. I have
> a question which have been bothering me for a while. I may have
> misunderstood something basic.
> 
> Jemalloc AFAIK synchronizes the allocations, as it is multithread-ready.
> However does Rust not use task-specific heaps? [I thought that most of
> the dynamic allocations happen in task-specific heaps.] For those is
> Jemalloc's synchronization not an unnecessary waste of processor time? 

Types like `Vec<T>` and `Box<T>` can be sent between tasks and `Arc<T>`
can be shared so there's no task-local heap. It's true that a few types
like `Rc<T>` are task-local but there would be no performance gain from
an extra layer. It would just create needless memory fragmentation.

jemalloc creates 4 arenas for every core (each with a lock) and assigns
threads to these arenas. It then has thread local caches on top of those.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to