From 4f0263633b40e94e8b69fd6e7e4395cfedfd5c12 Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Tue, 14 May 2024 10:11:24 -0400 Subject: [PATCH] server: free sampling contexts on exit (#7264) * server: free sampling contexts on exit This cleans up last leak found by the address sanitizer. * fix whitespace * fix whitespace --- examples/server/server.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index ceaeb1f76..7e0d068f8 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -671,6 +671,13 @@ struct server_context { model = nullptr; } + // Clear any sampling context + for (server_slot & slot : slots) { + if (slot.ctx_sampling != nullptr) { + llama_sampling_free(slot.ctx_sampling); + } + } + llama_batch_free(batch); }