Skip to content

Commit

Permalink
Stop panics on memory leaks in release
Browse files Browse the repository at this point in the history
Signed-off-by: emneo <emneo@kreog.com>
  • Loading branch information
emneo-dev committed Sep 8, 2024
1 parent 174337d commit f345c38
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const is_debug_build = builtin.mode == std.builtin.OptimizeMode.Debug;

pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit() != .ok) @panic("memory leaked");
defer {
// Don't panic in release builds, that should only be needed in debug
if (gpa.deinit() != .ok and is_debug_build)
@panic("memory leaked");
}
const allocator = gpa.allocator();

try logz.setup(allocator, .{
Expand Down

0 comments on commit f345c38

Please sign in to comment.