https://github.com/retrodev256/falloc
A temporary-file backed allocator for zig
https://github.com/retrodev256/falloc
zig-library zig-memory zig-modules zig-package
Last synced: 2 days ago
JSON representation
A temporary-file backed allocator for zig
- Host: GitHub
- URL: https://github.com/retrodev256/falloc
- Owner: RetroDev256
- License: mit
- Created: 2025-03-04T07:05:17.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-05T18:05:40.000Z (about 1 year ago)
- Last Synced: 2025-12-25T21:24:31.768Z (4 months ago)
- Topics: zig-library, zig-memory, zig-modules, zig-package
- Language: Zig
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ever wanted a zig allocator that could allocate all the free space of your HDD? Look no further! Really though, don't. Unless you have a specific need for this, you likely don't need it ;)
I created this allocator (POSIX systems only right now) for the purpose of single, *very* large allocations. Think lots and lots of math with hundreds of gigabytes in each array.
It is advised that you use ReleaseFast/ReleaseSmall when using this library. This is because the allocated memory is set to `undefined` by the Allocator interface, which may take a while for large allocations.
```zig
const std = @import("std");
const Allocator = std.mem.Allocator;
const falloc = @import("falloc");
pub fn main() !void {
const gpa: Allocator = falloc.allocator;
// 256 GiB of memory to work with
const mem = try gpa.alloc(u8, 1 << 38);
defer gpa.free(mem);
// In a real-world use case scenario, this would be better utilized.
const hello = "Hello, World!\n";
@memcpy(mem[0..hello.len], hello);
std.debug.print("{s}", .{mem[0..hello.len]});
}
```