You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, it would be nice to have a rust wrapper as part of mimalloc; also to ensure we get the best performance. I am not a Rust expert though but I will consider PR's (to dev3) in the contrib directory (much like the vcpkg one) that are clean and not too complex. I am not sure we want to be in the business of distributing crate's etc. but providing a basic wrapper would be good for any downstream crate. (no pressure on you OscarTHZhang -- I meant at in general to people that may be interested in this; I am also looking for a vcpkg maintainer :-) )
Hi! Traditionally, FFI bindings are separated into two crates: high-level bindings and raw C bindings (see this section of the cargo book for details). The raw binding crates are suffixed with -sys and do all the work of compiling/linking the C library. The high-level bindings include safe APIs and trait implementations like GlobalAlloc.
In this case, you have combined all this into a single crate. I recommend splitting this up, keeping the raw bindings in a mimalloc-sys crate and the high-level unsafe impl Allocator for MiMalloc in a second mimalloc crate.
The idea would be that others, like the mimalloc_rust repo, can just pull this in and wrap it in their own crate that they can publish (I don't think mimalloc itself should do this).
Daan (@daanx) would you be open to reconsidering this? The purpleprotocol/mimalloc_rust author appears to have gone inactive and the crate is no longer maintained: the last commit was in June, and the PR updating to v3.4.x (which fixes the thread heap init segfault, #1287) has been open since July without a response. The crate still bundles mimalloc v3.3.2, so its users are stuck with segfaults and memory corruption that are already fixed upstream.
In pyreqwest we switched to the official crate via a git dependency to fix these. That's easy for us since pyreqwest is an application-style cdylib shipped through PyPI, but library crates can't do that: crates.io doesn't allow git dependencies in published crates.
The mimalloc and mimalloc-sys crate names are unfortunately taken, but the official crates could be published as e.g. mimalloc-official / mimalloc-official-sys (or mimalloc-ms, mimalloc-microsoft). Publishing could be automated on release tags with crates.io trusted publishing from GitHub Actions, so it shouldn't add much maintenance work. I'm happy to help with this if needed, e.g. with a PR for the publishing workflow.
Activity
daanx commentedon Sep 16, 2026
Yes, it would be nice to have a rust wrapper as part of mimalloc; also to ensure we get the best performance. I am not a Rust expert though but I will consider PR's (to
dev3) in thecontribdirectory (much like thevcpkgone) that are clean and not too complex. I am not sure we want to be in the business of distributing crate's etc. but providing a basic wrapper would be good for any downstream crate. (no pressure on you OscarTHZhang -- I meant at in general to people that may be interested in this; I am also looking for a vcpkg maintainer :-) )dayvejones commentedon Oct 15, 2026
That's a very good idea
daanx commentedon Oct 17, 2026
I added an initial Rust crate in
dev3: https://github.com/microsoft/mimalloc/tree/dev3/contrib/rust -- let me know how it looks. The idea would be that others, like themimalloc_rustrepo, can just pull this in and wrap it in their own crate that they can publish (I don't think mimalloc itself should do this).OscarTHZhang commentedon Oct 23, 2026
I created a PR for introducing a safe arena binding: #1449
This is helpful for my own use case where I want to pre-register an mmap-ed region as arena for mimalloc's heap to allocate exclusively from.
Techcable commentedon Oct 23, 2026
Hi! Traditionally, FFI bindings are separated into two crates: high-level bindings and raw C bindings (see this section of the cargo book for details). The raw binding crates are suffixed with
-sysand do all the work of compiling/linking the C library. The high-level bindings include safe APIs and trait implementations likeGlobalAlloc.In this case, you have combined all this into a single crate. I recommend splitting this up, keeping the raw bindings in a
mimalloc-syscrate and the high-levelunsafe impl Allocator for MiMallocin a secondmimalloccrate.split the rust crate with a -sys crate as well, issue #1405
MarkusSintonen commentedon Nov 21, 2026
Daan (@daanx) would you be open to reconsidering this? The
purpleprotocol/mimalloc_rustauthor appears to have gone inactive and the crate is no longer maintained: the last commit was in June, and the PR updating to v3.4.x (which fixes the thread heap init segfault, #1287) has been open since July without a response. The crate still bundles mimalloc v3.3.2, so its users are stuck with segfaults and memory corruption that are already fixed upstream.In
pyreqwestwe switched to the official crate via a git dependency to fix these. That's easy for us sincepyreqwestis an application-stylecdylibshipped through PyPI, but library crates can't do that: crates.io doesn't allow git dependencies in published crates.The
mimallocandmimalloc-syscrate names are unfortunately taken, but the official crates could be published as e.g.mimalloc-official/mimalloc-official-sys(ormimalloc-ms,mimalloc-microsoft). Publishing could be automated on release tags with crates.io trusted publishing from GitHub Actions, so it shouldn't add much maintenance work. I'm happy to help with this if needed, e.g. with a PR for the publishing workflow.Vendor Microsoft mimalloc 3.7.0
build(deps): use official mimalloc release (#16740)