ona/src/coral/heap.zig

21 lines
506 B
Zig
Raw Normal View History

const builtin = @import("builtin");
const std = @import("std");
pub const allocator = switch (builtin.mode) {
2025-09-18 19:07:29 +01:00
.ReleaseFast, .ReleaseSmall => std.heap.smp_allocator,
else => debug_allocator.allocator(),
};
2025-09-18 19:07:29 +01:00
var debug_allocator = switch (builtin.mode) {
.ReleaseFast, .ReleaseSmall => {},
else => std.heap.DebugAllocator(.{}){},
};
pub fn traceLeaks() void {
2025-09-18 19:07:29 +01:00
switch (builtin.mode) {
.ReleaseFast, .ReleaseSmall => {},
else => _ = debug_allocator.detectLeaks(),
}
}