2025-05-12 00:21:52 +01:00
|
|
|
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-05-12 00:21:52 +01:00
|
|
|
};
|
|
|
|
|
|
2025-09-18 19:07:29 +01:00
|
|
|
var debug_allocator = switch (builtin.mode) {
|
|
|
|
|
.ReleaseFast, .ReleaseSmall => {},
|
|
|
|
|
else => std.heap.DebugAllocator(.{}){},
|
|
|
|
|
};
|
2025-05-12 00:21:52 +01:00
|
|
|
|
|
|
|
|
pub fn traceLeaks() void {
|
2025-09-18 19:07:29 +01:00
|
|
|
switch (builtin.mode) {
|
|
|
|
|
.ReleaseFast, .ReleaseSmall => {},
|
|
|
|
|
else => _ = debug_allocator.detectLeaks(),
|
|
|
|
|
}
|
2025-05-12 00:21:52 +01:00
|
|
|
}
|