From bfd766b7f3f86e81a52d09a4138a8ef79b9b2090 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Wed, 7 Aug 2024 17:25:16 +0700 Subject: [PATCH] fix: release resources in destructor (#179) Co-authored-by: vansangpfiev --- src/llama_engine.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/llama_engine.cc b/src/llama_engine.cc index 18f7cb29..fa9d455b 100644 --- a/src/llama_engine.cc +++ b/src/llama_engine.cc @@ -125,7 +125,13 @@ LlamaEngine::LlamaEngine() { log_disable(); } -LlamaEngine::~LlamaEngine() {} +LlamaEngine::~LlamaEngine() { + for(auto& [_, si]: server_map_) { + auto& l = si.ctx; + l.ReleaseResources(); + } + server_map_.clear(); +} void LlamaEngine::HandleChatCompletion( std::shared_ptr json_body,