Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jiacai2050/zig-jemalloc
Zig allocator baked by jemalloc
https://github.com/jiacai2050/zig-jemalloc
zig-library zig-package
Last synced: 29 days ago
JSON representation
Zig allocator baked by jemalloc
- Host: GitHub
- URL: https://github.com/jiacai2050/zig-jemalloc
- Owner: jiacai2050
- License: mit
- Created: 2024-04-03T04:37:38.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-27T11:26:01.000Z (about 2 months ago)
- Last Synced: 2024-10-27T13:04:20.505Z (about 2 months ago)
- Topics: zig-library, zig-package
- Language: C
- Homepage:
- Size: 879 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
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-10-16T08:45:54+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]]
[[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 [[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 vendored [[https://github.com/jemalloc/jemalloc/releases/tag/5.3.0][jemalloc(5.3.0)]] by default, you can disable this feature and link to the system-wide version using:
#+begin_src zig
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();
#+end_srcThen in you =main.zig=, initialize like this:
#+begin_src zig
const jemalloc = @import("jemalloc");
const allocator = jemalloc.allocator;
#+end_src