Skip to content

Implementation of malloc, realloc, calloc, and free in Rust.

Notifications You must be signed in to change notification settings

suzusuzu/malloc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

malloc-rs

Implementation of malloc, realloc, calloc, and free in Rust.

Note: No thread safe

Architecture

512 bytes or less is allocated by Segregated Free List, and more than 512 bytes is allocated by mmap.

Usage

git clone https://github.com/suzusuzu/malloc-rs.git
cd malloc-rs
cargo build
export LD_PRELOAD=`pwd`/target/debug/libmalloc_rs.so # malloc-rs allocator
# python3 -c 'print("hello world")'
unset LD_PRELOAD # system allocator

Demo

Python(numpy)

cargo build
export LD_PRELOAD=`pwd`/target/debug/libmalloc_rs.so
python3 <<EOF
import numpy as np
import random
while True:
    print(np.sum(np.random.random(random.randint(1000, 10000))))
EOF

vim(invader.vim)

mattn/invader-vim

cargo build
export LD_PRELOAD=`pwd`/target/debug/libmalloc_rs.so
wget https://raw.githubusercontent.com/mattn/invader-vim/master/plugin/invader.vim
vim
#:source ./invader.vim
#:Invader

About

Implementation of malloc, realloc, calloc, and free in Rust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages