I am implementing star cubing algorithm for data aggregation in c++(I am new to c++). In this algorithm we have big data. In first step we build a base tree using all data, then based on base tree we should build other trees,named star trees, after each star tree is completed, its values are outputted, and the star tree should be destroyed. I did all that process, my algorithm works, but its memory usage is very much, and it seems these star trees are not destroyed. Below is part of my code that I think is useful for this problem:
For each tree which I intend to destroy, I pass its root to destroyTree(node* root) method:
void Cagg::destroyTree(node* root){
int size = root->child.size();
for (int i = 0; i < size; i++){
destroyTree(root->child[i]);
}
delete root;
root = NULL;
}
when debugging, it seems node is deleted, but the memory usage of the program is going up exponentially while the program is creating more star trees, which means they are not destroyed. Moreover, the destructor is empty. I just delete nodes in this method. Thank you in advance for helping me.
Moreover I inherit node struct from another class. Is it possible that's the problem? and both class destructors are empty.