Skip to content

Commit

Permalink
Fix memory leak (#2475)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fix memory leak in IVFIndexInMem

Fix #2465

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
yangzq50 authored Jan 20, 2025
1 parent 00043a8 commit 9326fe1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/storage/knn_index/knn_ivf/ivf_index_data_in_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class IVFIndexInMemT final : public IVFIndexInMem {
}

~IVFIndexInMemT() {
std::unique_lock lock(rw_mutex_);
if (own_ivf_index_storage_) {
DecreaseMemoryUsageBase(MemoryUsed());
}
Expand Down Expand Up @@ -237,6 +238,7 @@ class IVFIndexInMemT final : public IVFIndexInMem {
BufferHandle handle = new_chunk_index_entry->GetIndex();
auto *data_ptr = static_cast<IVFIndexInChunk *>(handle.GetDataMut());
data_ptr->GetMemData(std::move(*ivf_index_storage_));
delete ivf_index_storage_;
ivf_index_storage_ = data_ptr->GetIVFIndexStoragePtr();
own_ivf_index_storage_ = false;
dump_handle_ = std::move(handle);
Expand Down

0 comments on commit 9326fe1

Please sign in to comment.