From 2ba66360c9c999be108a6d08ec8032b310220b31 Mon Sep 17 00:00:00 2001 From: greeshmay Date: Thu, 17 Nov 2022 12:12:51 -0800 Subject: [PATCH] fix: free ggml_context (close #149) (#150) * fix: free ggml_context * ggml : free the model's contexts in whisper_free() Co-authored-by: Georgi Gerganov --- whisper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/whisper.cpp b/whisper.cpp index d894f69..a8b9e71 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2169,6 +2169,12 @@ struct whisper_context * whisper_init(const char * path_model) { void whisper_free(struct whisper_context * ctx) { if (ctx) { + if (ctx->model.ctx) { + ggml_free(ctx->model.ctx); + } + if (ctx->model.ctx_mem) { + ggml_free(ctx->model.ctx_mem); + } if (ctx->buf_model) { delete ctx->buf_model; }