Browse Source

Added a Finalizer for `Conversation` in case it is not correctly disposed.

tags/v0.10.0
Martin Evans 2 years ago
parent
commit
0c2cff0e1c
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      LLama/Batched/Conversation.cs

+ 8
- 0
LLama/Batched/Conversation.cs View File

@@ -54,6 +54,11 @@ public sealed class Conversation
_end = end;
}

~Conversation()
{
Dispose();
}

/// <summary>
/// End this conversation, freeing all resources used by it
/// </summary>
@@ -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()


Loading…
Cancel
Save