Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.03 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.03 KB

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