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