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> {
139139
140140
141141 ~HierarchicalNSW () {
142+ clear ();
143+ }
144+
145+ void clear () {
142146 free (data_level0_memory_);
147+ data_level0_memory_ = nullptr ;
143148 for (tableint i = 0 ; i < cur_element_count; i++) {
144149 if (element_levels_[i] > 0 )
145150 free (linkLists_[i]);
146151 }
147152 free (linkLists_);
153+ linkLists_ = nullptr ;
154+ cur_element_count = 0 ;
155+ visited_list_pool_.reset (nullptr );
148156 }
149157
150158
@@ -658,6 +666,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
658666 if (!input.is_open ())
659667 throw std::runtime_error (" Cannot open file" );
660668
669+ clear ();
661670 // get file size:
662671 input.seekg (0 , input.end );
663672 std::streampos total_filesize = input.tellg ();
You can’t perform that action at this time.
0 commit comments