Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jiacai2050/zig-jemalloc
Zig allocator based on jemalloc
https://github.com/jiacai2050/zig-jemalloc
Last synced: about 2 months ago
JSON representation
Zig allocator based on jemalloc
- Host: GitHub
- URL: https://github.com/jiacai2050/zig-jemalloc
- Owner: jiacai2050
- License: mit
- Created: 2024-04-03T04:37:38.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-24T15:01:41.000Z (3 months ago)
- Last Synced: 2024-06-24T21:41:50.613Z (3 months ago)
- Language: Zig
- Size: 888 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - jiacai2050/zig-jemalloc
README
#+TITLE: zig-jemalloc
#+DATE: 2024-04-03T16:31:20+0800
#+LASTMOD: 2024-04-03T23:43:34+0800
#+AUTHOR: Jiacai Liu[[https://github.com/jiacai2050/zig-jemalloc/actions/workflows/CI.yml][https://github.com/jiacai2050/zig-jemalloc/actions/workflows/CI.yml/badge.svg]]
Zig memory allocator based on [[https://jemalloc.net/][jemalloc]].
* Usage
#+begin_src shell
zig fetch --save=jemalloc https://github.com/jiacai2050/zig-jemalloc/archive/${COMMIT}.tar.gz
#+end_srcReplace ~${COMMIT}~ with a real one, then in your =build.zig=, import the module like this:
#+begin_src zig
const dep_jemalloc = b.dependency("jemalloc", .{});
exe.root_module.addImport("jemalloc", dep_jemalloc.module("jemalloc"));
exe.linkLibC();
#+end_srcThis library will link to a vendored [[https://github.com/jemalloc/jemalloc/releases/tag/5.3.0][jemalloc(5.3.0)]] by default, you can disable it and link to system-wide with this:
#+begin_src zig
const dep_jemalloc = b.dependency("jemalloc", .{ .link_vendor = false });
// brew install jemalloc
// apt-get install libjemalloc-dev
exe.linkSystemLibrary("jemalloc");
exe.linkLibC();
#+end_srcThen in you =main.zig=, initialize like this:
#+begin_src zig
const jemalloc = @import("jemalloc");
const allocator = jemalloc.allocator;
#+end_src