Skip to content

Commit

Permalink
fix the memory leak in QBG search
Browse files Browse the repository at this point in the history
  • Loading branch information
masajiro committed Feb 27, 2025
1 parent c7b9bb7 commit aa3bca0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/NGT/HashBasedBooleanSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ template <typename TYPE> class HashBasedBooleanSet {
memset(_table, 0, tableSize * sizeof(TYPE));
}

~HashBasedBooleanSet() {
virtual ~HashBasedBooleanSet() {
delete[] _table;
_table = 0;
_stlHash.clear();
}

Expand Down
2 changes: 0 additions & 2 deletions lib/NGT/NGTQ/QuantizedBlobGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,11 +1375,9 @@ class Index : public NGTQ::Index {
//NGTQ::BooleanSet *checkedIDs = nullptr;
std::unique_ptr<NGTQ::BooleanSet> checkedIDs = nullptr;
if (quantizer.objectList.size() < 5000000) {
//checkedIDs = new NGTQ::BooleanVector(quantizer.objectList.size());
std::unique_ptr<NGTQ::BooleanVector> tmp(new NGTQ::BooleanVector(quantizer.objectList.size()));
checkedIDs = std::move(tmp);
} else {
//checkedIDs = new NGTQ::BooleanHash(quantizer.objectList.size());
std::unique_ptr<NGTQ::BooleanHash> tmp(new NGTQ::BooleanHash(quantizer.objectList.size()));
checkedIDs = std::move(tmp);
}
Expand Down
1 change: 1 addition & 0 deletions lib/NGT/NGTQ/Quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace NGTQ {

class BooleanSet {
public:
virtual ~BooleanSet() {};
virtual bool get(size_t idx) = 0;
virtual void set(size_t idx) = 0;
virtual bool operator[](size_t idx) = 0;
Expand Down
6 changes: 4 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
pybind11.get_include(True),
pybind11.get_include(False)],
'extra_compile_args': ['-std=c++11', '-Ofast',
'-march=x86_64' if platform.processor() == 'x86-64' else '',
'-march=x86-64' if platform.processor() == 'x86-64' or
platform.processor() == 'x86_64' else '',
'-DNDEBUG'],
'sources': ['src/ngtpy.cpp']
}
Expand All @@ -125,7 +126,8 @@
pybind11.get_include(True),
pybind11.get_include(False)],
'extra_compile_args': ['-std=c++11', '-Ofast',
'-march=haswell' if platform.processor() == 'x86-64' else '',
'-march=haswell' if platform.processor() == 'x86-64' or
platform.processor() == 'x86_64' else '',
'-DNDEBUG'],
'sources': ['src/ngtpy_avx2.cpp']
}
Expand Down

0 comments on commit aa3bca0

Please # to comment.