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 @@ -138,13 +138,21 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
138138
139139
140140 ~HierarchicalNSW () {
141+ clear ();
142+ }
143+
144+ void clear () {
141145 free (data_level0_memory_);
146+ data_level0_memory_ = nullptr ;
142147 for (tableint i = 0 ; i < cur_element_count; i++) {
143148 if (element_levels_[i] > 0 )
144149 free (linkLists_[i]);
145150 }
146151 free (linkLists_);
152+ linkLists_ = nullptr ;
153+ cur_element_count = 0 ;
147154 delete visited_list_pool_;
155+ visited_list_pool_ = nullptr ;
148156 }
149157
150158
@@ -659,6 +667,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
659667 if (!input.is_open ())
660668 throw std::runtime_error (" Cannot open file" );
661669
670+ clear ();
662671 // get file size:
663672 input.seekg (0 , input.end );
664673 std::streampos total_filesize = input.tellg ();
You can’t perform that action at this time.
0 commit comments