Skip to content

jiacai2050/zig-jemalloc

Repository files navigation

zig-jemalloc

https://github.com/jiacai2050/zig-jemalloc/actions/workflows/CI.yml/badge.svg https://img.shields.io/badge/zig%20version-0.13.0-blue.svg https://img.shields.io/badge/zig%20version-master-blue.svg

Zig allocator backed by jemalloc.

Usage

zig fetch --save=jemalloc https://github.com/jiacai2050/zig-jemalloc/archive/${COMMIT}.tar.gz

Replace ${COMMIT} with a real one, then in your build.zig, import the module like this:

const dep_jemalloc = b.dependency("jemalloc", .{});
exe.root_module.addImport("jemalloc", dep_jemalloc.module("jemalloc"));
exe.linkLibC();

This library will link to vendored jemalloc(5.3.0) by default, you can disable this feature and link to the system-wide version using:

const dep_jemalloc = b.dependency("jemalloc", .{ .link_vendor = false });
// Install jemalloc with system package manager, such as
// brew install jemalloc
// sudo apt-get install libjemalloc-dev
exe.linkSystemLibrary("jemalloc");
exe.linkLibC();

Then in you main.zig, initialize like this:

const jemalloc = @import("jemalloc");
const allocator = jemalloc.allocator;

About

Zig allocator baked by jemalloc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published