From e3776ff4b230a92d469313972d59c2abe2e279a1 Mon Sep 17 00:00:00 2001 From: presburger Date: Wed, 3 Aug 2022 21:44:33 +0800 Subject: [PATCH] fix dataset memory leak when use python api (#351) Signed-off-by: Yusheng.Ma --- python/knowhere/knowhere.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/knowhere/knowhere.i b/python/knowhere/knowhere.i index b478a11f4..a0cfb88f1 100644 --- a/python/knowhere/knowhere.i +++ b/python/knowhere/knowhere.i @@ -138,6 +138,8 @@ DumpResultDataSet(const knowhere::DatasetPtr& result, float* dis, int nq_1, int *(dis + i * k_1 + j) = *((float*)(dist_) + i * k_1 + j); } } + delete[] ids_; + delete[] dist_; } void @@ -146,6 +148,7 @@ DumpRangeResultIds(const knowhere::DatasetPtr& result, int* ids, int len) { for (int i = 0; i < len; ++i) { *(ids + i) = *((int64_t*)(ids_) + i); } + delete[] ids_; } void @@ -154,6 +157,7 @@ DumpRangeResultLimits(const knowhere::DatasetPtr& result, int* lims, int len) { for (int i = 0; i < len; ++i) { *(lims + i) = *((int64_t*)(lims_) + i); } + delete[] lims_; } void @@ -162,6 +166,7 @@ DumpRangeResultDis(const knowhere::DatasetPtr& result, float* dis, int len) { for (int i = 0; i < len; ++i) { *(dis + i) = *((float*)(dist_) + i); } + delete[] dist_; } knowhere::Config