Where to declare a global allocator?


I want to use jemallocator in an application, but I’m not sure where I should put the global allocator declaration: in lib.rs or in main.rs? Or does it not matter?


I think you put it in main.rs

1 Like

Since requiring that a library use a specific allocator would be a weird thing to do (libraries should be allocator-agnostic), it is indeed the application’s job (i.e., main.rs) to specify the allocator it wants to use.

1 Like

Thanks Yandros!