Where to declare a global allocator?

#1

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?

#2

I think you put it in main.rs

1 Like
#3

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
#4

Thanks Yandros!