File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -139,12 +139,20 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
139
139
140
140
141
141
~HierarchicalNSW () {
142
+ clear ();
143
+ }
144
+
145
+ void clear () {
142
146
free (data_level0_memory_);
147
+ data_level0_memory_ = nullptr ;
143
148
for (tableint i = 0 ; i < cur_element_count; i++) {
144
149
if (element_levels_[i] > 0 )
145
150
free (linkLists_[i]);
146
151
}
147
152
free (linkLists_);
153
+ linkLists_ = nullptr ;
154
+ cur_element_count = 0 ;
155
+ visited_list_pool_.reset (nullptr );
148
156
}
149
157
150
158
@@ -658,6 +666,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
658
666
if (!input.is_open ())
659
667
throw std::runtime_error (" Cannot open file" );
660
668
669
+ clear ();
661
670
// get file size:
662
671
input.seekg (0 , input.end );
663
672
std::streampos total_filesize = input.tellg ();
You can’t perform that action at this time.
0 commit comments