From ee8095d37d9813669688cf2f666756e607b84713 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sun, 23 Aug 2026 14:12:11 -0400 Subject: [PATCH] terminal/snapshot: use stack fallback for record scratch Use a bounded 512-byte stack fallback for complete-snapshot record scratch. Small records avoid heap growth while larger records continue through the heap allocator. --- src/terminal/snapshot/snapshot.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/terminal/snapshot/snapshot.zig b/src/terminal/snapshot/snapshot.zig index b2dfbe157..9c6dc96d4 100644 --- a/src/terminal/snapshot/snapshot.zig +++ b/src/terminal/snapshot/snapshot.zig @@ -50,7 +50,10 @@ pub fn encode( // Continuation errors must not emit even the snapshot envelope. try continuation.validate(options.continuation); - var stream: record.Writer = .init(alloc, destination); + // A measured 512-byte buffer handles our smallest records on the stack + // before larger records fall back to the heap. + var stack_alloc = std.heap.stackFallback(512, alloc); + var stream: record.Writer = .init(stack_alloc.get(), destination); defer stream.deinit(); // 1. Envelope