From 5292fdb41eb1c11c8da1cb9b6ed217c4f096a32e Mon Sep 17 00:00:00 2001 From: Micah Talkiewicz Date: Fri, 9 Aug 2024 15:40:13 -0400 Subject: [PATCH] Fix memory leak in src/llama.cpp Free `batch` before returning from `read_kv_cache_meta`. --- src/llama.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/llama.cpp b/src/llama.cpp index 97dd1b3fea4b9..37d4aab2715f3 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -17656,6 +17656,7 @@ struct llama_data_read { read_to(&n_seq_id, sizeof(n_seq_id)); if (n_seq_id != 0) { + llama_batch_free(batch); LLAMA_LOG_ERROR("%s: invalid seq_id-agnostic kv cell\n", __func__); return false; }