Jelajahi Sumber

server: free sampling contexts on exit (#7264)

* server: free sampling contexts on exit

This cleans up last leak found by the address sanitizer.

* fix whitespace

* fix whitespace
Steve Grubb 1 tahun lalu
induk
melakukan
4f0263633b
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      examples/server/server.cpp

+ 7 - 0
examples/server/server.cpp

@@ -671,6 +671,13 @@ struct server_context {
             model = nullptr;
         }
 
+        // Clear any sampling context
+        for (server_slot & slot : slots) {
+            if (slot.ctx_sampling != nullptr) {
+                llama_sampling_free(slot.ctx_sampling);
+            }
+        }
+
         llama_batch_free(batch);
     }