Fix mem leak when load index

Signed-off-by: xige-16 <xi.ge@zilliz.com>
This commit is contained in:
xige-16 2021-04-10 10:10:53 +08:00 committed by yefu.chen
parent 56d367b1e9
commit 22eda19bc4
3 changed files with 10 additions and 0 deletions

View File

@ -124,6 +124,12 @@ NewBinarySet(CBinarySet* c_binary_set) {
}
}
void
DeleteBinarySet(CBinarySet c_binary_set) {
auto binary_set = (milvus::knowhere::BinarySet*)c_binary_set;
delete binary_set;
}
CStatus
AppendBinaryIndex(CBinarySet c_binary_set, void* index_binary, int64_t index_size, const char* c_index_key) {
try {

View File

@ -41,6 +41,9 @@ AppendIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set);
CStatus
NewBinarySet(CBinarySet* c_binary_set);
void
DeleteBinarySet(CBinarySet c_binary_set);
CStatus
AppendBinaryIndex(CBinarySet c_binary_set, void* index_binary, int64_t index_size, const char* c_index_key);

View File

@ -73,6 +73,7 @@ func (li *LoadIndexInfo) appendFieldInfo(fieldID int64) error {
func (li *LoadIndexInfo) appendIndex(bytesIndex [][]byte, indexKeys []string) error {
var cBinarySet C.CBinarySet
status := C.NewBinarySet(&cBinarySet)
defer C.DeleteBinarySet(cBinarySet)
errorCode := status.error_code
if errorCode != 0 {