3 ms·
It's not really that hard of a problem. You just use a different allocator (like the author did in this article). In fact, you can even write your own allocator
by robot_no_421 4y ago
It's not really that hard of a problem. You just use a different allocator (like the author did in this article). In fact, you can even write your own allocator with unsafe if you want (jemalloc is already using a lot of unsafe in the code anyway, you need to use it to build any real allocator).
'unsafe' doesn't equal 'don't use'. I'll admit that unsafe Rust has a lot of rough and unergonomic features compared to C, but it's conceptually and algorithmically just as easy (or hard) in Rust to build an allocator as it is in C and C++.
You also still get the help of the borrow checker in unsafe rust, so there are even some advantages.