diff --git a/LLama/Batched/Conversation.cs b/LLama/Batched/Conversation.cs index a699bb66..b3ce97dd 100644 --- a/LLama/Batched/Conversation.cs +++ b/LLama/Batched/Conversation.cs @@ -54,6 +54,11 @@ public sealed class Conversation _end = end; } + ~Conversation() + { + Dispose(); + } + /// /// End this conversation, freeing all resources used by it /// @@ -66,6 +71,9 @@ public sealed class Conversation // Remove this conversation from the KV cache Executor.Context.NativeHandle.KvCacheRemove(ConversationId, 0, _end); + + // Prevent finalizer from running + GC.SuppressFinalize(this); } private void AssertNotDisposed()