summaryrefslogtreecommitdiff
path: root/src/memory.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.zig')
-rw-r--r--src/memory.zig18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/memory.zig b/src/memory.zig
index e5394b4f..a2c5547c 100644
--- a/src/memory.zig
+++ b/src/memory.zig
@@ -101,20 +101,26 @@ var pdf_debug: Debug = .init;
// One session at a time; free its allocations before deinit. Concurrent LSP workers use the caller's allocator.
pub fn init(fallback: Allocator) Allocators {
- pardes_fallback.fallback_allocator = fallback;
- frame_fallback.fallback_allocator = fallback;
+ // A Debug build puts each allocator under a DebugAllocator of its own,
+ // which reports that subsystem's leaks and bad frees (deinit panics on a
+ // leak). Beneath that goes the page allocator rather than `fallback`: in
+ // a Debug build `fallback` is std.process.Init's gpa, a DebugAllocator
+ // already, and a second one checked every block twice.
+ const backing = if (debug_enabled) std.heap.page_allocator else fallback;
+ pardes_fallback.fallback_allocator = backing;
+ frame_fallback.fallback_allocator = backing;
frame_fallback.get_called = if (std.debug.runtime_safety) false else {};
- tree_sitter_fallback.fallback_allocator = fallback;
+ tree_sitter_fallback.fallback_allocator = backing;
tree_sitter_fallback.get_called = if (std.debug.runtime_safety) false else {};
- image_fallback.fallback_allocator = fallback;
+ image_fallback.fallback_allocator = backing;
image_fallback.get_called = if (std.debug.runtime_safety) false else {};
- pdf_fallback.fallback_allocator = fallback;
+ pdf_fallback.fallback_allocator = backing;
pdf_fallback.get_called = if (std.debug.runtime_safety) false else {};
const raw: Allocators = .{
.pardes = pardes_fallback.get(),
.frame = frame_fallback.get(),
- .lsp = fallback,
+ .lsp = backing,
.tree_sitter = tree_sitter_fallback.get(),
.image = image_fallback.get(),
.pdf = pdf_fallback.get(),