summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/macos.zig b/src/macos.zig
index 3ff8bdfa..b19c5996 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -692,8 +692,15 @@ export fn pardes_init(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) c_
return 0;
}
+/// The shell's gpa in a Debug build, as std.start's is for the others.
+var debug_gpa: std.heap.DebugAllocator(.{}) = .init;
+
fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void {
- const gpa = std.heap.smp_allocator;
+ // The allocator every other shell gets from std.start: a DebugAllocator
+ // in Debug, libc's malloc otherwise. libc's measured at least as fast as
+ // std.heap.smp_allocator everywhere and faster on MuPDF's page-sized
+ // rasters, so this shell no longer differs.
+ const gpa = if (builtin.mode == .Debug) debug_gpa.allocator() else std.heap.c_allocator;
const allocs = pardes.memory.init(gpa);
errdefer pardes.memory.deinit();
@@ -824,6 +831,11 @@ export fn pardes_deinit() void {
st.threaded.deinit();
st.gpa.destroy(st.threaded);
pardes.memory.deinit();
+ // Leaks are logged and do not fail, as std.start treats the others'.
+ if (builtin.mode == .Debug) {
+ _ = debug_gpa.deinit();
+ debug_gpa = .init;
+ }
state = null;
}