From 38e4c34a0ecc72ae05b2682c619842ee298ea9ea Mon Sep 17 00:00:00 2001 From: haturatu Date: Mon, 30 Sep 2024 21:29:49 +0900 Subject: first commit --- README.md | 37 +++++++++++++++++++++++++++++++++++++ example | Bin 0 -> 881232 bytes main.c | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 README.md create mode 100755 example create mode 100644 main.c diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1490f6 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# mimalloc-testing +## What is mimalloc? +This is code for testing mimalloc. +A very small code, an allocator for memory management with excellent performance. + +it has also been implemented in Rust. i tested it io integrate it into the software. + +## install mimalloc +``` +git clone https://github.com/microsoft/mimalloc +cd mimalloc/ +mkdir -p build +cd build/ +cmake .. +make +sudo make install +``` + +## Compile with GCC +Now, let's compile using GCC. +``` +git clone https://github.com/haturatu/mimalloc-testing.git +cd mimalloc-testing +gcc main.c -o example -lmimalloc +./example +``` +or static link +``` +$ find /usr/local -name "libmimalloc.a" +/usr/local/lib/mimalloc-1.8/libmimalloc.a +``` +Okay, i found it. +``` +gcc main.c -o example -static -L/usr/local/lib/mimalloc-1.8/ -lmimalloc +./example +``` +Done! diff --git a/example b/example new file mode 100755 index 0000000..f945ceb Binary files /dev/null and b/example differ diff --git a/main.c b/main.c new file mode 100644 index 0000000..82788cd --- /dev/null +++ b/main.c @@ -0,0 +1,19 @@ +#include +#include + +int main() { + int* arr = (int*) malloc(5 * sizeof(int)); + + for (int i = 0; i < 5; i++) { + arr[i] = i * 10; + } + + for (int i = 0; i < 5; i++) { + printf("%d ", arr[i]); + } + + free(arr); + + return 0; +} + -- cgit v1.2.3