Code Monkey home page Code Monkey logo

mimalloc-rust's Introduction

The Best and Highest-Leveled and Newest binding for MiMalloc Ever Existed in Rust

mimalloc 2.1.2 stable

ci doc.rs crates.io

Why create this

in repo https://github.com/purpleprotocol/mimalloc_rust i didn't see any data types and it neither has all the functionalities which mimalloc has provided, in other words it's garbage.

Usage

first add to dependencies

[dependencies]
mimalloc-rust = "0.2.1"

then set the global allocator

use mimalloc_rust::*;

#[global_allocator]
static GLOBAL_MIMALLOC: GlobalMiMalloc = GlobalMiMalloc;

mimalloc-rust's People

Contributors

aml360 avatar aumetra avatar brooooooklyn avatar kdy1 avatar lemonhx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mimalloc-rust's Issues

UB: GlobalHeap should not be creatable from arbitrary pointers

Since GlobalHeap can be created from an arbitrary pointer, and code assumes heaps always have valid pointers, it is easy to cause UB:

use mimalloc_rust::heap::GlobalHeap;
use mimalloc_rust::heap::MiMallocHeap;
use mimalloc_rust::*;

#[global_allocator]
static GLOBAL_MIMALLOC: GlobalMiMalloc = GlobalMiMalloc;

fn main() {
    let new_heap = GlobalHeap {
        heap: std::ptr::null_mut(),
    };

    GlobalMiMalloc::replace_by(&MiMallocHeap::new(new_heap));
 }

Guard nightly-only api usage (e.g. `feature(allocator_api)`) behind a feature gate

This crate is nightly-only, but it's not stated in the ReadMe nor the main documentation (lib.rs does this). Many users use stable Rust release, and this crate should be usable in stable environment, albeit with missing features (e.g. Allocator API) instead of being completely unable to compile at all.

Solution

Guard Allocator API usage behind a feature gate, and release a stable version with the Allocator trait items implemented without specifying the trait.

Alternative solution

Write ๐Ÿšง๐Ÿšง๐Ÿšง This crate is Nightly Only ๐Ÿšง๐Ÿšง๐Ÿšง in readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.