Skip to content

Commit 224acef

Browse files
authored
MB-61093 Fix memory leak for SQDistanceComputer (#43)
* Use unique_ptr to manage SQDistanceComputer lifecycle.
1 parent 3001b51 commit 224acef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

faiss/IndexScalarQuantizer.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ void IndexIVFScalarQuantizer::compute_distance_to_codes_for_list(
289289
const uint8_t* codes,
290290
float* dists) const {
291291

292-
ScalarQuantizer::SQDistanceComputer* dc =
293-
sq.get_distance_computer(metric_type);
292+
std::unique_ptr<ScalarQuantizer::SQDistanceComputer> dc(
293+
sq.get_distance_computer(metric_type));
294+
294295
dc->code_size = sq.code_size;
295296

296297
if (by_residual) {

0 commit comments

Comments
 (0)