{"id":13710623,"url":"https://github.com/dweiller/zimalloc","last_synced_at":"2025-05-06T19:32:14.987Z","repository":{"id":175620646,"uuid":"653027350","full_name":"dweiller/zimalloc","owner":"dweiller","description":"General purpose allocator for Zig","archived":false,"fork":false,"pushed_at":"2025-03-10T11:13:23.000Z","size":152,"stargazers_count":37,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T11:41:56.816Z","etag":null,"topics":["zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dweiller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-13T09:15:13.000Z","updated_at":"2025-03-10T11:09:15.000Z","dependencies_parsed_at":"2023-10-16T03:34:09.303Z","dependency_job_id":"dfdd6827-d63f-4dc4-ae33-1f155b69c9fa","html_url":"https://github.com/dweiller/zimalloc","commit_stats":null,"previous_names":["dweiller/zimalloc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweiller%2Fzimalloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweiller%2Fzimalloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweiller%2Fzimalloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweiller%2Fzimalloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dweiller","download_url":"https://codeload.github.com/dweiller/zimalloc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252753637,"owners_count":21798987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zig-package"],"created_at":"2024-08-02T23:00:59.036Z","updated_at":"2025-05-06T19:32:09.901Z","avatar_url":"https://github.com/dweiller.png","language":"Zig","readme":"# zimalloc\n\nzimalloc is general purpose allocator for Zig, inspired by [mimalloc](https://github.com/microsoft/mimalloc).\n\n## Status\n\nThis project is under development and should currently be considered experimental/exploratory; there\nis no documentation and it has not been battle-tested. In particular there may be issues with\nmulti-threaded workloads. Contributions of any kind (PRs, suggestions for improvements, resources or\nideas related to benchmarking or testing) are welcome.\n\nThe allocator is significantly faster than `std.heap.GeneralPurposeAllocator(.{})` but should not\n(yet) be expected to be competitive with other established general purpose allocators.\n\n## Usage\n\nTo use the allocator in your own project you can use the Zig package manager by putting this in your\n`build.zig`\n```zig\npub fn build(b: *std.Build) void {\n    // -- snip --\n    const zimalloc = b.dependency(\"zimalloc\").module(\"zimalloc\"); // get the zimalloc module\n    // -- snip --\n    exe.addModule(zimalloc); // add the zimalloc module as a dependency of exe\n    // -- snip --\n}\n```\nand this to the dependencies section of your `build.zig.zon`\n```zig\n    .zimalloc = .{\n        .url = \"https://github.com/dweiller/zimalloc/archive/[[COMMIT_SHA]].tar.gz\"\n    },\n```\nwhere `[[COMMIT_SHA]]` should be replaced with full SHA of the desired revision. You can then import\nand initialise an instance of the allocator as follows:\n```zig\nconst zimalloc = @import(\"zimalloc\");\npub fn main() !void {\n    var gpa = try zimalloc.Allocator(.{}){};\n    defer gpa.deinit();\n\n    const allocator = gpa.allocator();\n    // -- snip --\n}\n```\n\n### Shared library\n\nThere is a shared library that can be used for overriding standard libc allocation functions.\nIt can be accessed from your `build.zig` like so:\n```zig\npub fn build(b: *std.Build) void {\n    // -- snip --\n    const libzimalloc = b.dependency(\"zimalloc\").artifact(\"zimalloc\"); // get the zimalloc shared library\n    // -- snip --\n    exe.linkLibrary(zimalloc); // link to libzimalloc\n    // -- snip --\n}\n```\n\nIf you just want to build the shared library and use it outside the Zig build system, you can build\nit with the `libzimalloc` or `install` steps, for example:\n```sh\nzig build libzimalloc -Doptimize=ReleaseSafe\n```\n\n## Notes\n\n  - The current implementation works on Linux, with other systems untested.\n  - The main suite of tests currently used is `https://github.com/daanx/mimalloc-bench`\n    which are run using `LD_PRELOAD`. Not all tests have been tried, but all those that have been tested\n    run successfully.\n  - No attempt has been made to make the allocator signal-safe.\n","funding_links":[],"categories":["Language Essentials"],"sub_categories":["Memory Allocator and Management"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdweiller%2Fzimalloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdweiller%2Fzimalloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdweiller%2Fzimalloc/lists"}